LCD Solar Panel Read
LCD Solar Panel Read
LCD Solar Panel Read
1. This project shows a morse code on a 16*2 LCD using a solar panel as the trigger when a light is shone upon it. A buzzer and
LED triggers when solar panel passes data.
2. Make SURE solar panel is connected properly. One side is positive other is negative voltage. Recommend using a diode on
one side to be safe.
3. if buzzer+led is on all the time, your analog value is high, if off all time even when laser pointer or flashlight shines on the lcd
panel, its too low. adjust the values on line 53-54 after reading from the serial monitor using the AnalogReadPanel_voltage
code. Shine your light or laser on the panel to get your high value and subtract a few millivolts. Adjust low value as well. As the
day goes on, ambient light levels will change causing the panel to falsely trigger.
4. I havent got the second row of the 16*2 LCD screen to show anything. If you manage to get that going then please post your
code on my site, I would like to admire it :)
5. Long presses (i.e. char '0' = '-----') are made by keeping the solar panel high for a short period.
6. If your LCD doesnt have I2C on it, youll need a lot more wires to connect it and maybe have to adjust the brightness with a
potentiometer. You can just display the morse code on the serial terminal alternatively.
https://www.entrepreneur.com/article/253376
Arduino code:
//https://create.arduino.cc/projecthub/vladakrsmanovic/arduino-morse-code-machine-709cc5
//chansey.weebly.com
#include <LiquidCrystal_I2C.h>
int lastButtonState = LOW;//start itof as low (also resets to this when line lastButtonState=buttonState; runs)
int doesitwork = LOW; // variable used for debuging early versions of the code
int pause_value = 150; //{250} depending on your skill and how fast your fingers are you can change this value to make typing a
message faster or slower
long signal_length = 0;
long pause = 0;
long lastDebounceTime = 0;
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup()
Serial.begin(9600);
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(buzzer, OUTPUT);
lcd.setCursor(0,0);
//Serial.println("Using these values print out your message in morse and read out the message in english in the serial
monitor");
//while(!analogRead(buttonPin))
void loop() {
if (buttonState > 0.25) buttonParse = HIGH; // *IMPORTANT: will need to change values according to ambient light to
voltage (measure with readAnalogVoltage example)
//Serial.println(buttonState);
if (buttonParse && lastButtonState) // basic state machine depending on the state of the signal from the button
++signal_length;
if (signal_length<pause_value) //this help to notice that there is a change in the signal length aka that its not a dot
anymore but a dash
{ // best use for the measuring of signal_length would be use of the millis() but this was used for
simplicity
tone(buzzer, 1500) ; //this is a faster buzzer tone (higher pitch) for a dot in this case
else
tone(buzzer, 500) ;
else if(!buttonParse && lastButtonState) //this part of the code happens when the button is released and it send either *
or - into the buffer
else if (signal_length>pause_value)
signal_length=0;
digitalWrite(ledPin, LOW);
noTone(buzzer);
else if(buttonParse && !lastButtonState) // this part happens when the button is pressed and its use to reset several
values
pause=0;
digitalWrite(ledPin, HIGH);
lcd.backlight();
cheker = true;
linecheker = true;
}
else if (!buttonParse && !lastButtonState) //no press action of button (both are false gives delta T pause times)
++pause;
printaj(morse);
lcd.leftToRight();
cheker = false;
morse = "";
Serial.println();
lcd.print(" ");
linecheker = false;
if (pause>40*pause_value){
lcd.clear();
if (pause>43*pause_value) lcd.noBacklight();
delay(1);
void printaj(String prevodilac) //ugly part of the code but it works fine
{ //compare morse string to known morse values and print out the letter or a number
//the code is written based on the international morse code, one thing i changed is that insted of typing a
special string to end the line it happens with enough delay
if (prevodilac=="*-"){
Serial.print("A");
lcd.print("A");
else if (prevodilac=="-***"){
Serial.print("B");
lcd.print("B");
else if (prevodilac=="-*-*"){
Serial.print("C");
lcd.print("C");
else if (prevodilac=="-**"){
Serial.print("D");
lcd.print("D");
else if (prevodilac=="*"){
Serial.print("E");
lcd.print("E");
else if (prevodilac=="**-*"){
Serial.print("F");
lcd.print("F");
else if (prevodilac=="--*"){
Serial.print("G");
lcd.print("G");
else if (prevodilac=="****"){
Serial.print("H");
lcd.print("H");
else if (prevodilac=="**"){
Serial.print("I");
lcd.print("I");
else if (prevodilac=="*---"){
Serial.print("J");
lcd.print("J");
else if (prevodilac=="-*-"){
Serial.print("K");
lcd.print("K");
else if (prevodilac=="*-**"){
Serial.print("L");
lcd.print("L");
else if (prevodilac=="--"){
Serial.print("M");
lcd.print("M");
else if (prevodilac=="-*"){
Serial.print("N");
lcd.print("N");
else if (prevodilac=="---"){
Serial.print("O");
lcd.print("O");
else if (prevodilac=="*--*"){
Serial.print("P");
lcd.print("P");
else if (prevodilac=="--*-"){
Serial.print("Q");
lcd.print("Q");
else if (prevodilac=="*-*"){
Serial.print("R");
lcd.print("R");
}
else if (prevodilac=="***"){
Serial.print("S");
lcd.print("S");
else if (prevodilac=="-"){
Serial.print("T");
lcd.print("T");
else if (prevodilac=="**-"){
Serial.print("U");
lcd.print("U");
else if (prevodilac=="***-"){
Serial.print("V");
lcd.print("V");
else if (prevodilac=="*--"){
Serial.print("W");
lcd.print("W");
else if (prevodilac=="-**-"){
Serial.print("X");
lcd.print("X");
else if (prevodilac=="-*--"){
Serial.print("Y");
lcd.print("Y");
else if (prevodilac=="--**"){
Serial.print("Z");
lcd.print("Z");
}
else if (prevodilac=="*----"){
Serial.print("1");
lcd.print("1");
else if (prevodilac=="**---"){
Serial.print("2");
lcd.print("2");
else if (prevodilac=="***--"){
Serial.print("3");
lcd.print("3");
else if (prevodilac=="****-"){
Serial.print("4");
lcd.print("4");
else if (prevodilac=="*****"){
Serial.print("5");
lcd.print("5");
else if (prevodilac=="-****"){
Serial.print("6");
lcd.print("6");
else if (prevodilac=="--***"){
Serial.print("7");
lcd.print("7");
else if (prevodilac=="---**"){
Serial.print("8");
lcd.print("8");
else if (prevodilac=="----*"){
Serial.print("9");
lcd.print("9");
else if (prevodilac=="-----"){
Serial.print("0");
lcd.print("0");
Serial.print(" ");