Based on the Tinkercad circuit accessible from the link below, complete the following activities: https://www.tinkercad.com/things/c1qtxCkOuBW Code is, // C++ code // const byte LED_PIN = 13; const byte METER_PIN = A4; void setup() { pinMode(LED_PIN, OUTPUT); pinMode(METER_PIN, INPUT); Serial.begin(
Based on the Tinkercad circuit accessible from the link below, complete the following activities:
https://www.tinkercad.com/things/c1qtxCkOuBW
Code is,
// C++ code
//
const byte LED_PIN = 13;
const byte METER_PIN = A4;
void setup()
{
pinMode(LED_PIN, OUTPUT);
pinMode(METER_PIN, INPUT);
Serial.begin(9600);
startTimer();
}
void loop()
{
}
void startTimer(){
noInterrupts();
interrupts();
}
ISR(TIMER1_COMPA_vect){
digitalWrite(LED_PIN, digitalRead(LED_PIN) ^ 1);
}
1. Complete the code in a way that LED blinks every 2 seconds.
2. Change the startTimer method to accept a double value called timerFrequency, which represents
the frequency of the timer. Change the startTimer function so that it uses the value of this parameter
to calculate and set the correct values for the OCRx and TCCRx registers.
3. Use the potentiometer sensor connect to pin A4 to enable users to configure the timer frequency
Step by step
Solved in 3 steps