1. Connection
- Run the Arduino IDE (Integrated Development Environment)
- Tools, Boards, Select the right type (Ask.)
- Tools, Port, Select the right port (Ask.)
2. Blink
- File, Examples, Basics, Blink.
- Save it (so you can modify it)
- Load to Arduino (ctrl-u)(^u)
- See the lights flash as it loads and runs.
- If it doesn’t work, probably the connection (above) is wrong.
- Change the timing.
- Change which LED is flashing.
- Use an int to eliminate triplicated led number.
- 2 leds flashing?
3. Light Dependent Resistor
- File, Examples, Basics, AnalogReadSerial
- Save
- at the end of the program change delay(1) to delay(200)
- Load and run ^u
- Tools, Serial Monitor – and see the Arduno printing zeros.
- Add this line into the setup function: pinMode(A0, INPUT_PULLUP);
- Load, Run, Look at Serial Monitor. – Changing numbers?
- Put your hand over the LDR to make it dark.
- Close Serial Monitor and open Serial Plotter.
4. Questions
Lots of things to think about.
- What is each physical component?
- What is each item in the program?
- Voltage? Current?
- Resistance? Resistors?
- What is that waveform on the LDR graph?
- What is Serial?
Read all the comments in each program!
- ‘Arduno LED circuit’
- ‘Arduino LDR circuit’
- ‘Serial Communication’
5. Switch
- File, Examples, Basics, Digital, Button
- Save
- Change the button pin number (line 26) to the pin where your switch is connected.
- Change INPUT (line 36) to INPUT_PULLUP
- Load, Run – see switch turns led on.
- Change which led it controls.
(Google or Ask)
Make a number count.
Make the LDR switch a LED on and off.
(These are not complete instructions, Try, Google, Ask)
- Another value on the plot
- And another.
- Change that value to count.
- count % number (create a new variable (scope!))
- count * count
- value set to 1000 when switch pressed, then counts down to zero.
- Light on during count down.
- Names on the values.
- Leds on/off on schedule.
- count wrap round,
o unsigned int ?
o use long ?
- Floats
- Boolean
- (Strings)
- Read the serial into your own application.
- Read the DHT11 temperature sensor.