You are on page 1of 2

DEVICES lcd.

setCursor (0,0);
lcd.print (“ “);
1. LED
- longer side (+) – resistor – digital pin 7. PUSHBUTTON SWITCH (pullup)
- shorter (-) – ground

2. POTENTIOMETER
- 1st – voltage input – 5V
- 2nd – analog pin (A0)
- 3rd – ground

3. PHOTORESISTOR
1 = w/o current 0 = w/current
*If pull down resistor, resistor is on GND side.
0 = w/o current 1 = w/ current

8. SOUND/NOISE SENSOR
4. RGB LED
- RBG (TinkerCad)

9. WATER LEVEL SENSOR


- (-) – ground
- (+) – 5V
- S – Analog Pin

10. KEYPAD MATRIX


5. TEMPERATURE & HUMIDITY SENSOR
#include <Keypad.h>
#include “DHT.h”; const byte numRows = 4;
DHT sensor (pin, DHT22); // or DHT11 const byte numCols = 4;

loop: char keymap [numRows] [numCols] =


temp = sensor.readTemperature (); {
humidity = sensor.readHumidity (); { ‘1’, ‘2’, ‘3’, ‘A’},
{ ‘4’, ‘5’, ‘6’, ‘B’},
{ ‘7’, ‘8’, ‘9’, ‘C’},
6. LIQUID CRYSTAL DISPLAY (LCD) { ‘*’, ‘0’, ‘#’, ‘D’}
};

byte rowPins [numRows] = {digital pins};


byte colsPins [numCols] = {digital pins};
Keypad myKeypad = Keypad
(makeKeymap (keymap), rowPins,
colsPins, numRows, numCols);

#include <LiquidCrystal_I2C.h> loop:


#include <Wire.h> char keypressed = myKeypad.getKey ();
LiquidCrystal_I2C lcd = LiquidCrystal_I2C
(0x27, 16, 2); // (32,16,2) TinkerCad if (keypressed != NO_KEY){
//statements
setup: }
lcd.begin (16,2);
lcd.home (); // (0,0) 11. BUZZER

loop: - (+) – 5V
lcd.init (); - (-) - ground
lcd.backlight ();
FUNCTIONS STRUCTURES

1. pinMode 1. if
- pinMode (pin, OUTPUT/INPUT); - if (condition){
//statements
2. digitalWrite }
- digitalWrite (pin, HIGH/LOW)
2. for
3. delay - for
- delay (milliseconds); (initialization;condition;increment){
// statements
4. analogWrite }
- brightness/speed (0-255)
- analogWrite (pin, 0-255) 3. while
- while (condition){
5. analogRead // statements
- 0 – 1023 increment
- analogRead (pin); }

6. digitalRead - while (Serial.available ()== 0){


- 0 or 1 } //waiting
- digitalRead (pin);
4. else
- if (condition)[
// statement
VARIABLES }
1. int
- -32 768 to 32 768 else if (condition)[
- int var = val; //statement
}
2. float else{
- decimal //statement
- float var = val; }

3. long 5. do .. while
- > 32 768 - do {
- long var = val; // statement
increment
4. String
- String var = val; } while (condition);

5. byte
- byte var = val; ● SERIAL MONITOR

6. char setup:
- char myChar = ‘val’; //single quote Serial.begin (9600);
- char myChar = val; //ASII Chart
loop:
Serial.print ();
variable = Serial.parseInt ();
variable = Serial.parseFloat ();
variable = Serial.readString ();

You might also like