You are on page 1of 7

Print Your Name: __________________________________

Red Box Number:______

Arduino Microcontroller Exercises
An Open-Source Single-Board Protot ping Plat!orm In this in-class exercise we will improve upon previous circuits and code that we had developed using the Arduino Microcontroller. Procedure Put a check (√) in each box to the left as ou complete each task.

 !ogin to our computer as an Administrator. !ocate the Arduino
folder on the desktop or go to the "#omework $ocuments% link on the course home page (www.danbruton.com&'()*+*) and download the Arduino ,ip file to our desktop.

 -se a -./ cable to connect the Arduino Microcontroller to our computer. 0hen go to
Start " #ontrol Panels " S stem " $ard%are &tab' " (e)ice Manager* If ou see an unrecogni1ed "-./ $evice% then do the following2 3. )ight click on "-./ $evice% and select -pdate $river. 4. .elect "5es6 now and ever time I connect the device%. *. .elect "Install from a list or specific location%. +. 0he browse to the Arduino "drivers% folder. 7. 0hen click Next and +inis, after successful installation. In the $evice Manager window under Ports (89M :!P0) what is the port number for the Arduino -;9 )* device (e.g. 89M36 89M46 etc.)< Answer2 ===========

 8lose the $evice Manager and start the Arduino environment. 0o run the Arduino environment6
locate and execute >arduino.exe> in the Arduino folder on our desktop.

 9pen the !'$ blink example sketch2 Arduino " +ile " Examples " -*Basics " Blin..
.elect our microcontroller board2 Arduino " /ools " Serial Port " &Select Your Port'

 ;ow click the >-pload> button in the environment as shown to
the right. ?erif Microcontroller. that !'$ 3* is blinking on our Arduino

 8onnect a ellow !'$ and **@Ω resistor in series on our red
breadboard. Place this series connection between pin 3* and (;$. /e ver careful not to connect the !'$ directl between Pin 3* and (;$. It is important to have the resistor in series with the !'$. ?erif that the ellow !'$ blinks along with the !'$ that is located on the Arduino board.

-pload

 8onnect another **@Ω resistor in series with a red !'$ on a
separate area on our breadboard. between (;$ and pin 34. 8onnect this series pair

 Modif the code so that the red and ellow !'$ alternate at a
rate of about + times each second. working circuit. .how our instructor our

InstructorAs Approval2 ========= .

0he s ntax is tone(pin6 freCuenc 6 duration). (entl push the connectors of the . int Max = 200. .g.100%. 8onnect a Dlex .how our instructor our working circuit.oftPot to pin A@6 and the outside pins of the .ensor between pin A@ and B7?. InstructorAs Approval2 =========  .  )ecord the maximum and minimum values read b the . Maximum2 ============= Minimum2 =============== Add the follow code before the setup() function in our code.oftPot in various places (e. int freqout = 440.oftPot and (.erial to the Arduino Microcontroller. . (Arduino " /ools " Serial Monitor).oftPot to B7? and ground.$ and pin A@. !eave the 3@k Ω resistor connected between (.oftPot from our circuit. 5ou should hear the pitch change as the flex sensor is bent. from the top of the sensor to the bottom).erial code (Arduino " +ile " Examples " -*Basics " AnalogReadSerial). //Replace with your minimum serial value //Replace with your maximum serial value //An output frequency of 440 ! is concert A  0he tone function in the Arduino environment generates a sCuare wave of the specified freCuenc on a pin.oftPot into the red breadboard. int Min = 100.ing Music .ow remove the .Ma. . tone". Monitor the readings using the serial monitor.freqout./. Dor example6 tone(E6 ++@6 3@@)F will pla a ++@#1 tone for 3@@ milliseconds to a bu11er connected to pin E.  5ou should hear a tone onl when our press various parts of the .oftPot. 0o convert the range of serial sensor values to this freCuenc range6 we can use the following code inside the loop() function2 if "sensor#alue $ 100% & freqout = 440'0 ( "sensor#alue ) Min% * "++0'0 ) 440'0% / "Max ) Min%.$ to act as a pull-down resistor.. 0he freCuencies ++@#1 and GG@#1 both correspond to the musical note A6 but one octave apart.erial Monitor while ou are touching the .e So!tPot and Bu00er  !oad the Analog)ead. InstructorAs Approval2 ========= . Attach the center pin of the . Also6 add a 3@kΩ resistor between the center pin of the .how our instructor our working circuit. -pload Analog)ead.

0herefore it is acceptable if the !'$ does not light up instantl .$. (Arduino " /ools " Serial Monitor). 8onnect pin A@ to the Hunction between the resistor and thermistor.how our instructor our working circuit.e P.$ and B7?. -pload Analog)ead. 8onnect this series pair between (. InstructorAs Approval2 ========= $eat (etector . Place this series connection between pin 33 and (.otoresistor  8onnect 3@kΩ resistor in series with a photoresistor on our breadboard.$.ermistor  8onnect 3@kΩ resistor in series with a thermistor on our breadboard.erial to the Arduino Microcontroller.how our instructor our working circuit. .e /. 8onnect pin A@ to the Hunction between the resistor and photoresistor. -pload Analog)ead. Monitor the readings using the serial monitor.t 1ig.erial example code (Arduino " +ile " Examples " -*Basics " AnalogReadSerial).  8onnect a red !'$ and **@Ω resistor in series on our red breadboard.  !oad the Analog)ead. Monitor the readings using the serial monitor.$ and B7?. Place this series connection between pin 3@ and (.erial example code (Arduino " +ile " Examples " -*Basics " AnalogReadSerial). ./.  $evelop code that will cause the red !'$ to light up when ou place our finger on top of the thermistor. .  8onnect a ellow !'$ and **@Ω resistor in series on our red breadboard.ote that it ma take some time for the resistance of the thermistor to change.erial to the Arduino Microcontroller. (Arduino " /ools " Serial Monitor)./.Nig.t . InstructorAs Approval2 ========= . 8onnect this series pair between (.  !oad the Analog)ead.  $evelop code that will cause the ellow !'$ to light up when ou place our finger on top of the photoresistor.

InstructorAs Approval2 ========= (ebounce . because of a push-button press)6 the output pin is toggled from !9I to #I(# or #I(# to !9I. 0here is a minimum dela between toggles to debounce the circuit (i. to ignore noise).Pulse 2idt.  8onnect an oscilloscope between pin E and (.  8onnect a button between pin 4 to B7?.$. -pload (ebounce to the Arduino Microcontroller. 0he !'$ is actuall blinking so fast that our e es cannot detect it -much like a computer monitor or 0?.ote that the !'$ is getting brighter and dimmer because of a techniCue called >Pulse 2idt. InstructorAs Approval2 ========= .Button  8onnect a ellow !'$ and **@Ω resistor in series on our red breadboard.$.$.g.  In the code6 change debounce$ela to 3@@@ and note the effect on the behavior of the circuit. Place this series connection between pin 3* and (. Place this series connection between pin E and (.+ade . . -pload +ade to the Arduino Microcontroller. Modulation  8onnect a ellow !'$ and **@Ω resistor in series on our red breadboard.  Is the waveform a sawtooth wave6 sCuare wave6 or sine wave< ===========================  . 8onnect a 3@kΩ resistor between from pin 4 and (.e.  'ach time the input pin goes from !9I to #I(# (e.how our instructor our working circuit.  !oad the (ebounce example code (Arduino " +ile " Examples " 3*(igital " (ebounce).$ and monitor the output waveform. Modulation>.  !oad the +ade example code (Arduino " +ile " Examples " -*Basics " +ade ).

345045%. Re/0in 1reen0in = = . pinMo/e"2lue0in. -se Humper wires to connect the other side of the resistors to pins E6 3@ and 33 of the Arduino microcontroller.    8onnect a button between pin 4 to B7?. At the top of our program initiali1e variables that will define the pins used as follows2 int int int 2lue0in = 10.t ..345045%. !ocate three **@Ω resistors.$ pin of the Arduino microcontroller. 8onnect a 3@kΩ resistor between from pin 4 and (. /ra!!ic 1ig. Place these * resistors across the valle of the breadboard and connect them to pins 36 * and + of the 0ri-8olor !'$.  Inside of the setup() function ou must declare these pins as outputs.$./ri-#olor 1E(   8onnect pin 4 of the 0ri-8olor !'$ to the (.345045%. pinMo/e"Re/0in. !oad the (ebounce example code (Arduino " +ile " Examples " 3*(igital " (ebounce).#ross%al. 11. . pinMo/e"1reen0in.

%.else& analo9:rite "Re/0in. InstructorAs Approval2 =========  . 0hink of this as a protot pe for a crosswalk traffic light.. 0he following code will turn on the red component of the 0ri-8olor !'$ when the button is pressed if it is placed at the bottom of the loop() function.how our instructor our working circuit. . if "6utton7tate == 81 %& analo9:rite "Re/0in.0%.2. //:rite the output //:rite the output  Irite addition code that will cause the 0ri-8olor !'$ to go through the following seCuence of colors if the button is pressed2 green for 7 seconds6 ellow for 4 seconds6 and then run on red again until the button is pressed again. . .