char led_red = 23;
char led_green = 18;
char led_yellow = 19;
char led_red_state = LOW;
char led_green_state = LOW;
char led_yellow_state = LOW;
long led_red_previous_millis = 0;
long led_green_previous_millis = 0;
long led_yellow_previous_millis = 0;
long ADC_previous_millis = 0;
int led_red_interval = 1000;
int led_green_interval = 1000;
int led_yellow_interval = 1000;
int ADC_interval = 1000;
void setup() {
// put your setup code here, to run once:
pinMode(led_red, OUTPUT);
pinMode(led_green, OUTPUT);
pinMode(led_yellow, OUTPUT);
// Initialize serial communication
Serial.begin(9600);
}
void loop() {
long current_millis = millis();
// Blinking red LED
if (current_millis - led_red_previous_millis >= led_red_interval) {
led_red_previous_millis = current_millis;
// now reverse the led's state
if (led_red_state == LOW)
led_red_state = HIGH;
else
led_red_state = LOW;
// control the led accordingly
digitalWrite(led_red, led_red_state);
}
// Read ADC value
if (current_millis - ADC_previous_millis >= ADC_interval) {
ADC_previous_millis = current_millis;
// Read ADC value
int ADC_value = analogRead(A5); // ensure A5 is the correct pin for ADC reading
// Print ADC value to the Serial Monitor
Serial.print("Analog Reading: ");
Serial.println(ADC_value);
}
}