take your Arduino skills to the next level by using libraries. this describes a follow-up workshop for people who have already done the Arduino introduction workshop
3. standard Arduino workshop 2017
Before we start… check the connection between your
Arduino board and your laptop:
● plugin your Arduino board USB cable into your laptop
● open Arduino IDE software (www.arduino.cc)
● open the Blink sketch from File>Examples>Basic
● pick the correct port from Tools>Serial Port
● pick the correct board type from Tools>Board “Uno”
● hit ‘upload’ to test the connection
● look for ‘Done uploading’ and check if the onboard LED
is blinking
13. standard Arduino workshop 2017
Breadboard power rails
5V to red line
GND to blue line
Optional:
connect to other side
14. standard Arduino workshop 2017
Arduino libraries
Some common libraries
are already included in
the IDE
Other libraries have to
be added as you need
them:
● library manager
● add .zip file
● add manually in
library folder
15. standard Arduino workshop 2017
LCD library: LiquidCrystal
Already included in the IDE
Each library comes with examples: a good starting point
Go to File > Examples > LiquidCrystal > HelloWorld
16. standard Arduino workshop 2017
LCD wiring
Find the wiring details in the comments
or google ‘arduino lcd’ for images
18. standard Arduino workshop 2017
DHT sensor
Temperature and Humidity sensor (not very accurate)
Vcc = 5V
Data
GND
One digital pin for data transfer (specific digital protocol)
19. standard Arduino workshop 2017
DHT library
Not included in IDE, need to add
Go to: Sketch > Include Library > Manage Libraries..
Search for ‘DHT’ and install the Adafruit library
in browser, search for ‘github adafruit unified sensor’
https://github.com/adafruit/Adafruit_Sensor
‘clone or download’ download ZIP
Go to: Sketch > Include Library >
Add .ZIP library
20. standard Arduino workshop 2017
DHT library
File > Examples > DHT sensor library > DHTtester
DHTPIN 6
DHTTYPE DHT11
Upload
Open Serial Monitor
21. standard Arduino workshop 2017
LCD + DHT sketch
Copy lines from DHT sketch into LCD sketch
in loop:
Read DHT sensor
Display temp and humidity on the LCD
Wait 2 seconds
22. standard Arduino workshop 2017
Add buzzer for temp alarm
in loop:
Read DHT sensor
Display temp and humidity on the LCD
If temp > 30deg: buzzer beeps
Wait 2 seconds
23. standard Arduino workshop 2017
Add pot for temp alarm
in loop:
Read DHT sensor
Read temp alarm pot
Display temp, alarm, hum on the LCD
If temp > alarm: buzzer beeps
Wait 2 seconds
24. standard Arduino workshop 2017
Add button for hum alarm
in loop:
Read DHT sensor
If button pressed: read hum alarm
else: read temp alarm
Display temp, hum, alarms on the LCD
If temp > alarm OR hum > alarm:
buzzer beeps
Wait 2 seconds
25. standard Arduino workshop 2017
Use timestamp instead of delay
in loop:
If button pressed: read hum alarm
else: read temp alarm
Display temp, hum, alarms on the LCD
If temp > alarm OR hum > alarm:
buzzer beeps
If 2 seconds passed:
read DHT sensor
26. standard Arduino workshop 2017
Use timestamp
unsigned long timestamp = 0;
void loop() {
[code here is executed every loop]
if (millis() - timestamp > 2000) {
[code here only every 2 seconds]
read sensor
timestamp = millis();
}
}
27. standard Arduino workshop 2017
Arduino: suppliers
ONLINE
➔ Official Arduino shop: http://arduino.cc/
great documentation, projects, forum
➔ Seeedstudio: http://www.seeedstudio.com/depot/
➔ Telesky: https://telesky.world.tmall.com/
➔ Adafruit: http://www.adafruit.com/ great documentation
IN HONG KONG - Apliu St
➔ WECL http://www.weclonline.com/wecl_eng/index.html
➔ Tell How http://tellhow-tech.com/
28. standard Arduino workshop 2017
Dimsum Labs
the hackerspace of HK www.dimsumlabs.com/
community of technology enthusiasts
space for creativity in Sheung Wan
Tuesday evening HackJam
www.facebook.com/groups/hackjamhk/