Professional Documents
Culture Documents
ME 106 Fundamentals of Mechatronics Homework #3: Programming the Arduino Due 2/28/13 Hardcopy (in lecture) and Softcopy (in D2L)
Use the answer template to record your homework responses. Dont forget to include the summary of the assignment on the cover page of the answer template (what you did, how you did it, and what you learned). Where written responses are requested, please type them. Make sure that you show how you arrive at any answers involving numerical calculations. Answers that do not show intermediate steps will likely not get any points. Photocopy, photograph, or scan your work, so that you have a back up copy. ************************** 1. Get an Arduino board. Arduino Microcontroller (Duemilanove or UNO R3). Sources for these
boards include: NKC Electronics , Adafruit Industries, Sparkfun Electronics, Modern Device, Radio Shack, and many others..
2. Go to http://arduino.cc/en/Main/Software, download the Arduino software, and install it on a computer that you will use for your homework or project work. See the Getting Started web page for instructions on installing the Arduino software (http://arduino.cc/en/Guide/HomePage). 3. Review the handout on Bit Manipulation, http://www.engr.sjsu.edu/bjfurman/courses/ME106/lectures/handout_bit_manipulation.doc, and the addendum, http://www.engr.sjsu.edu/bjfurman/courses/ME106/lectures/handout_bit_manipulation_adde ndum.doc 4. Binary HEX Decimal conversions a. (2 pts) Convert the binary number 10100111 to HEX b. (2 pts) Convert the HEX number 7A to binary c. (2 pts) What would the following C statement evaluate to? 0x17 > 17; Explain your answer. d. (2 pts) Evaluate as a decimal number the statement, 0xD6 0b11000110; e. (2 pts) What is decimal 145 expressed in HEX? 5. (10 pts) Write two programs to run on the Arduino that will do the following: a. Make pins D2 and D3 be outputs, and pins D0, D1, D4 D7 to be inputs b. Turn on pullup resistors for D0 and D1 only c. Repeat forever alternating making D2 and D3 high and low with a one second delay between the change in state of the two pins. In other words, the pattern is: when one of D2 or D3 is high the other is low. Every second thereafter, the state of the pins flips (the one that was high goes low, and the one that was low goes high). Write one of the programs using Arduino style programming. Write the second program using the more general port-style approach (i.e., without using the built-in Arduino
Page 1 of 2
Extra Credit: Write a program that will allow you to execute the pattern from Problem 7, but using all ten of the LEDs on the PortMaster shield. [Again, to have any hope of getting credit for this problem, your code must be fully and wellcommented]
Page 2 of 2