A c program code is required to run on the atmega16 Light sensing and timed buzz
ID: 3582684 • Letter: A
Question
A c program code is required to run on the atmega16
Light sensing and timed buzzer Specifications:
Write and test a C program called lab11b.c that combines the light sensor and a buzzer. The program should first let the user enter the delay n by pressing a digit on the keypad followed by the hash key (#). The program then monitors continuously the light intensity. When the light becomes dark, the program will wait for n seconds before turning on the buzzer.
A video demonstration of the program is at https://youtu.be/zAnAK35s8RU
Explanation / Answer
#define DIN_LIGHT_SENSOR 1 //Digital input channel 1
class MyRobot: public SimpleRobot
{
//
// This is to declare the light sensor object to be a digital input object.
//
DigitalInput lightSensor;
DriverStationLCD *dsLCD;
//
// This initialize the light sensor object specifying the digital input channel.
//
MyRobot():
lightSensor(DIN_LIGHT_SENSOR),
dsLCD(DriverStationLCD::GetInstance())
{
}
void OperatorControl()
{
while (IsEnabled() && IsOperatorControl())
{
UINT32 value = lightSensor.Get();
dsLCD->PrintfLine(DriverStationLCD::kUserLine1, "value=%d", value);
Wait(0.1);
}
}
};
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.