Title of Media
Some of people like warm light and the other prefer cold light , so I want to make lighting unit with 2 or 3 lighting source , you can change warm or cold as you prefer , and to be suitable to your activities like " read , sleep , work ". If there are two partner in one place , every one of them can change the light type as he like.
Software: Arduino IDE
Title of Media
3 resistor 220 ohm
Arduino uno
Breadboard
Potentiometer
Jumper Wires (Male - Male)
3 Led with three colour (red-green-yellow)
LCD display 16x2
Title of Media
Title of Media
I searched online for something could change led light colour between three led light using Potentiometer and show numbers on lcd screen , every colour has number shown on screen
So I found this "Simple LED Meter Using Potentiometer and I2C LCD " and it will give me the same result .
Also I searched for simple lamp could be made by card board , I found Chinese lamp , I change the dimensions little bit to put breadboard .
The link of circuit on tinker cad :
I want to make the sensor value change with the colour of led
when the sensor is 4 , red led will light
when the sensor is 3 , green led will light
when the sensor is 1-2 , yellow led will light
so I wrote the code that make this steps work
also I connect the lcd to Arduino , and want the value of sensor appear on it's screen.
and this project uses the I2C LCD. Using this LCD requires libraries to be installed in your Arduino IDE , so download the LiquidCrystal_V1.2.1 and Wire zip files , then add them to the libraries of Arduino
the code :
#include <Wire.h>
#include <FastIO.h>
#include <I2CIO.h>
#include <LCD.h>
#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidCrystal_SR.h>
#include <LiquidCrystal_SR2W.h>
#include <LiquidCrystal_SR3W.h>
#include <Wire.h> //enables us to use i2c communication
#include <LiquidCrystal_I2C.h> //enables us to use the lcd functions
//I2C pins declaration
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); //lcd is a user-defined name
int sensorValue = 0;
int led_1=4, led_2=5,led_3=6;
void setup()
{
lcd.begin(16,2);
lcd.backlight();
pinMode(led_1,OUTPUT);
pinMode(led_2,OUTPUT);
pinMode(led_3,OUTPUT);
}
void loop()
{
sensorValue=analogRead(A0);
sensorValue=map(sensorValue,0,1023,1,5);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Value is: ");
lcd.print(sensorValue);
delay(500);
if (sensorValue <= 2){ //sensorValue is less than or equal to 2
digitalWrite(led_1,HIGH);
digitalWrite(led_2,LOW);
digitalWrite(led_3,LOW);
}
else if (sensorValue==3){
digitalWrite(led_1,LOW);
digitalWrite(led_2,HIGH);
digitalWrite(led_3,LOW);
}
else if (sensorValue>=3){ //sensorValue is greater than or equal to 3
digitalWrite(led_1,LOW);
digitalWrite(led_2,LOW);
digitalWrite(led_3,HIGH);
}
}
The smart device is wired and tested with an actual Arduino board , led , LCD , Potentiometer on a breadboard
I had two problems , first one when I wiring the circuit , one led work and the others didn't work , I try to change the resistor , the jumpers , the led , doesn't work . after a lot of tries I discover that the two led were on the other side in the bread board and the two sides didn't connect . so I move them in one side in the bread board
Title of Media
Second one , I can't add the LiquidCrystal_V1.2.1 to Arduino library , and the LCD didn't work and didn't show the value , and the code couldn't upload to Arduino
I search and found the way to add it to library through this website https://arduinointro.com/projects/displaying-characters-using-the-i2c-liquid-crystal-display-lcd
Step 1. First, download the LiquidCrystal_V1.2.1 and Wire zip files.
Step 2. Open your Arduino IDE and from the menu bar, go to Sketch->Include Library->Add .ZIP Library..
Step 3. Browse to where you saved the zip files and select one file at a time, then click Open. In this case, we select the LiquidCrystal_V1.2.1 zip file first.
After clicking Open, the library is now installed.
Step 4. Repeat the same process to include the Wire library.
Title of Media
My final project I am confused about using LCD to show the degree of temperature of cup of tea , or make led changing color by sensor feel the temperature , so I want to learn more about led and LCD and how to connect them with breadboard and how to write the code for them . so this Idea wad very useful for me.
Before I start to make week 7 Idea , I made small exercise . I connect circuit feel temperature by LM35 sensor and display the numbers on LCD screen , and the number change by the temperature of room , It was so cool .
Title of Media