User Tools

Site Tools


workshops:arduino_for_the_curious:stage_2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
workshops:arduino_for_the_curious:stage_2 [2017-04-05 12:52] – external edit 127.0.0.1workshops:arduino_for_the_curious:stage_2 [2017-04-10 11:22] (current) Simon
Line 4: Line 4:
  
 This stage involves the following new components. This stage involves the following new components.
-  *  Push Button - [[pushbutton|more info]] +  *  [[pushbutton|Push Button]] 
-  *  Potentiometer (Rotation Sensor) - [[potentiometer|more info]]+  *  [[potentiometer|Potentiometer (Rotation Sensor)]]
  
  
Line 15: Line 15:
 {{workshops:tut2-sch1_bb.png?0x400}} {{workshops:tut2-sch1_bb.png?0x400}}
  
-| {{workshops:challenge_yourself.jpg?200x0}}| **Easier****(1)** By modifying the code from the single LED program, and using the knowledge you've learn from the presentation, make the LEDs flash in the sequence 1,2,3,4,5,1,2,3...**Intermediate****(2)** Now change it so that the LEDs flash in the sequence 1,2,3,4,5,4,3,2,1,2... |+| {{workshops:challenge_yourself.jpg?200x0}}| **Easier** \\ **(1)** By modifying the code from the single LED program, and using the knowledge you've learn from the presentation, make the LEDs flash in the sequence 1,2,3,4,5,1,2,3... \\ \\ **Intermediate** \\ **(2)** Now change it so that the LEDs flash in the sequence 1,2,3,4,5,4,3,2,1,2... |
  
  
Line 22: Line 22:
  
  
-We're now going to use the pushbutton to control the direction of the LEDs going through their sequence. When the button is not pressed the lights should go 0,1,2,3,4,0,1,2,3..., when it is pressed the lights should go 4,3,2,1,0,4,3,2...+We're now going to use the push button to control the direction of the LEDs going through their sequence. When the button is not pressed the lights should go 0,1,2,3,4,0,1,2,3..., when it is pressed the lights should go 4,3,2,1,0,4,3,2...
  
 Note: the buttons in your kit have bent legs. It's worth using a pair of pliers to straighten them out.  Note: the buttons in your kit have bent legs. It's worth using a pair of pliers to straighten them out. 
Line 30: Line 30:
 {{workshops:tut2-sch2_bb.png?0x400}} {{workshops:tut2-sch2_bb.png?0x400}}
  
-Below is the code for controlling LEDs with the pushbutton. It stops the LEDs when the button is pressed. +Below is the code for controlling LEDs with the push button. It stops the LEDs when the button is pressed.
  
 +<code>
 // Button is on pin 7 // Button is on pin 7
 int button = 7; int button = 7;
Line 70: Line 70:
   }   }
 } }
 +</code>
  
- +| {{workshops:challenge_yourself.jpg?200x0}}| **Harder** \\ **(1)** Try to change the code so that the LEDs change direction while the button is pressed. |
-| {{workshops:challenge_yourself.jpg?200x0}}| **Harder****(1)** Try to change the code so that the LEDs change direction while the button is pressed. |+
  
  
Line 84: Line 84:
 The Arduino's analog inputs are on the left side of the board and are labelled A0 through to A5. You can read the voltage on pin A0 as follows: The Arduino's analog inputs are on the left side of the board and are labelled A0 through to A5. You can read the voltage on pin A0 as follows:
  
 +<code>
 // The reading will be a number between 0 and 1023, where 0 is 0V, 1023 is 5V, and all the numbers in between are the voltages inbetween // The reading will be a number between 0 and 1023, where 0 is 0V, 1023 is 5V, and all the numbers in between are the voltages inbetween
 // For example a reading of 512 (which is right in the middle of the range) would be a voltage of 2.5V. // For example a reading of 512 (which is right in the middle of the range) would be a voltage of 2.5V.
 int reading = analogRead(0); int reading = analogRead(0);
 +</code>
  
 Place the rotation sensor on the breadboard and wire it up to the Arduino as follows: Place the rotation sensor on the breadboard and wire it up to the Arduino as follows:
Line 94: Line 94:
 {{workshops:tut2-sch3_bb.png?0x400}} {{workshops:tut2-sch3_bb.png?0x400}}
  
-Remember using the serial communication in Lesson 1 to allow the Arduino to send data back to your laptop? We can use that to see how the value output by our rotation sensor varies as we rotate it. +Remember using the serial communication in [[stage_1|Lesson 1]] to allow the Arduino to send data back to your laptop? We can use that to see how the value output by our rotation sensor varies as we rotate it.
  
 +<code>
 void setup() {                 void setup() {                
   // initialize serial communication at a speed of 9600 bits per second:   // initialize serial communication at a speed of 9600 bits per second:
Line 108: Line 108:
   delay(500);               // wait for half second   delay(500);               // wait for half second
 } }
 +</code>
  
- +| {{workshops:challenge_yourself.jpg?200x0}}| **Easier** \\ **(1)** Use the reading of the rotation sensor voltage, change the length of the delay in the loop. This should cause the LED flashing sequence to change speed when you turn the knob. |
-| {{workshops:challenge_yourself.jpg?200x0}}| **Easier****(1)** Use the reading of the rotation sensor voltage, change the length of the delay in the loop. This should cause the LED flashing sequence to change speed when you turn the knob. |+
  
  
workshops/arduino_for_the_curious/stage_2.1491396766.txt.gz · Last modified: 2017-04-05 12:52 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki