Need help writing this code in C. Also how would you build this circuit? Using a
ID: 3840506 • Letter: N
Question
Need help writing this code in C. Also how would you build this circuit?
Using a photo sensor, display the binary output of the measured light on the 10 segment LED block. Use a switch (not a button) to put the system into one or the other of two modes. The display must range from near 0 to near 1023. Mode 1: Display the measured light continuously. Mode 2: Capture the measured light when a push button has been pressed (the button must be denounced) and display it on the LED block. Part 2: Read a letter (a-z) from the serial monitor and display the corresponding Morse code on an LED and in text on the monitor (dot dot dash). You must use an array to retrieve the appropriate Morse code.Explanation / Answer
#include <LiquidCrystal.h>
int tempPin = 0;
int lightPin = 1;
// BS E D4 D5 D6 D7
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void setup()
{
lcd.begin(16, 2);
}
void loop()
{
// Display Temperature in C
int tempReading = analogRead(tempPin);
float tempVolts = tempReading * 5.0 / 1024.0;
float tempC = (tempVolts - 0.5) * 100.0;
float tempF = tempC * 9.0 / 5.0 + 32.0;
// ----------------
lcd.print("Temp F ");
lcd.setCursor(6, 0);
lcd.print(tempF);
// Display Light on second row
int lightReading = analogRead(lightPin);
lcd.setCursor(0, 1);
// ----------------
lcd.print("Light ");
lcd.setCursor(6, 1);
lcd.print(lightReading);
delay(500);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.