Presentation is loading. Please wait.

Presentation is loading. Please wait.

Microcontroller Hands-on Workshop #2 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers October 31, 2009.

Similar presentations


Presentation on theme: "Microcontroller Hands-on Workshop #2 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers October 31, 2009."— Presentation transcript:

1 Microcontroller Hands-on Workshop #2 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers October 31, 2009

2 2 Preliminary Information  Workshop schedule  Competition rules  Parts list  Checking-out parts  Teams  Weekly evaluation forms

3 3 Agenda for Today  Quick Review  Varying LED brightness  Controlling multiple LEDs  Sensors/Actuators (pots & light sensors)  Controlling devices using sensor input

4 4 Arduino Development Cycle

5 5 Arduino Programming  Declare variables, defines, and includes at top

6 6 Arduino Programming  Setup() –run once at beginning, set pins

7 7 Arduino Programming  loop() –run repeatedly, after setup()

8 8 Common Constructs  if (i < 10) { // statement(s) } else if(i > 10){ // statement(s) } else { // statement(s) }  for ( i = 0; i < 10; i++) {// statement(s)}  while(expression){ // statement(s)}

9 9 Arduino Common Functions  pinMode() –set a pin as input or output  digitalWrite() –set a digital pin high/low  digitalRead() –read a digital pin’s state  analogRead() –read an analog pin  analogWrite() –write an “analog” value  delay() –wait an amount of time

10 10 Today’s Kit 1.Arduino Microcontroller/ USB Cable 2.Breadboard 3.Resistor: 220 ohm, 10K ohm 4.6x Red LED 5.CdS Cell 6.Wires

11 11 Varying LED  Same circuit as Blink circuit but pin 9 instead of pin 13

12 12 Wire it up!  Going from schematic to physical circuit

13 13 Solderless Breadboard

14 14 All Wired Up!

15 15 LED Fading Sketch  Load “File/Sketchbook/Examples/Analog/Fading”

16 16 Controlling Multiple LEDs

17 17 Controlling Multiple LEDs

18 18 Controlling Multiple LEDs Sketch

19 19 Sensors Light Sound Temperature Motion Acceleration Position Proximity Bearing Altitude Location Humidity Magnetic field Pressure Flow Bend/Stretch Capacitance (touch) RF energy

20 20 Cadmium Sulfide (CdS) Cell – The Photoresistor Variable resistor that changes resistance depending on the amount of light shined upon it. It has no polarity (you can wire either way) Bright light creates low resistance No light creates high resistance

21 21 Controlling LED using CdS Cell input

22 22 Controlling LED using CdS Cell input Code

23 Questions or Comments? 23


Download ppt "Microcontroller Hands-on Workshop #2 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers October 31, 2009."

Similar presentations


Ads by Google