Lesson 9
Activity 2 Part (ii) - Buttons
Codes:
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int readkey;
void setup() {
lcd.begin(16, 2);
lcd.print("How are you");
lcd.setCursor(0, 1);
lcd.print("today?");
}
void loop()
{
readkey=analogRead(0);
if (readkey<50) {
lcd.clear();
lcd.print("Happy");
}
else if(readkey<195) {
lcd.clear();
lcd.print("Sad");
}
else if(readkey<380) {
lcd.clear();
lcd.print("Excited");
}
else if(readkey<790) {
lcd.clear();
lcd.print("Bored");
}
}
Monday, 26 September 2016
Lesson 9: Activity 2(LCD Shield)
Lesson 9
Activity 2: LCD Shield
Material Needed:
Codes:
#include <LiquidCrystal.h>
LiquidCrystal lcd (8,9,4,5,6,7);
void setup()
{
lcd.begin(16,2);
}
void loop()
{
lcd.home();
lcd.print("How are you ");
delay (500);
lcd.setCursor(0,1);
lcd.print("today???");
delay (500);
lcd.clear();
delay (500);
}
* Note: Please change the Pin value from the previous activity
Monday, 19 September 2016
Lesson 9: Activity 1(Displaying Characters on LCD Panel)
Lesson 9
Activity 1: Displaying Characters on LCD Panel
Material Needed:
Activity 1: Displaying Characters on LCD Panel
Material Needed:
- Laptop
- USB cable
- Breadboard
- Arduino Board
- LCD Panel
- 14 x Jumper Wires
#include <LiquidCrystal.h>
LiquidCrystal lcd (8,9,10,11,12,13);
void setup()
{
___._____(16,2);
___._____(16,2);
}
void loop()
{
lcd.home();
lcd.print("How are you");
delay (1000);
lcd.setCursor(0,1);
___._____("today 1R3???");
delay (1000);
____.______();
delay (1000);
}
Pin No. :
Pin 1: GND Bus
Pin 2: Live Bus
Pin 3: GND Bus
Pin 4: Digital Pin 8
Pin 5: GND Bus
Pin 6: Digital Pin 9
Pin 7: Empty
Pin 8: Empty
Pin 9: Empty
Pin 10: Empty
Pin 11: Digital Pin 10
Pin 12: Digital Pin 11
Pin 13: Digital Pin 12
Pin 14: Digital Pin 13
Pin 15: Live Bus
Pin 16: GND Bus
Pin 2: Live Bus
Pin 3: GND Bus
Pin 4: Digital Pin 8
Pin 5: GND Bus
Pin 6: Digital Pin 9
Pin 7: Empty
Pin 8: Empty
Pin 9: Empty
Pin 10: Empty
Pin 11: Digital Pin 10
Pin 12: Digital Pin 11
Pin 13: Digital Pin 12
Pin 14: Digital Pin 13
Pin 15: Live Bus
Pin 16: GND Bus
Lesson 8: Activity 1(Testing Heart Rate Sensor)
Lesson 8
Activity 1 - Testing Heart Rate Sensor
Materials Needed:
Activity 1 - Testing Heart Rate Sensor
Materials Needed:
- Arduino Board
- Breadboard
- USB Cable
- Laptop
- Heart Rate ear-clip sensor
- 5 x Jumper Wires
Codes:
const int heartPin = ?;
void setup()
{
Serial.begin(9600);
pinMode(heartPin, ?);
}
void loop()
{
if(digitalRead(heartPin)>0)
{
Serial.println("Reading");
}
else
{
Serial.println("0");
}
}
Monday, 12 September 2016
Lesson 7: Activity 2 (Temperature Warning System)
Lesson 7
Activity 2 - Temperature Warning System
Materials Needed:
Activity 2 - Temperature Warning System
Materials Needed:
- Arduino Board
- Breadboard
- USB Cable
- Laptop
- Temperature Sensor
- Buzzer
- 1 x 330Ω
- 1 x LED
- 9 x Jumper Wires
int analogVal;
const int tempPin = A0;
float
voltage;
float
temperature;
const int led
= ?;
const int
buzzer = 6;
void
setup()
{
pinMode(tempPin, INPUT);
pinMode(led,?);
pinMode(buzzer,?);
Serial.begin(9600);
}
void loop()
{
analogVal=analogRead(tempPin);
voltage = (analogVal/1024.0)*5.0;
temperature = 100*voltage-50;
Serial.println(temperature);
delay(200);
if (temperature>30.0)
{
digitalWrite
(led,?);
digitalWrite
(buzzer,?);
delay (100);
}
else
digitalWrite(led,LOW);
digitalWrite(buzzer,LOW);
delay (100);
}
Subscribe to:
Posts (Atom)