Hello Friends,
I have performed an experiment on Simple waveform Generator.
Please refer follwing link:
I have come across a problem of Button Debouncing and I modified the waveform code. I successfully implemented it using interrupt function. Now I have to used Polling mechanism without attachInterrupt Function. Is there any sample code for beginner to understand Polling. I know the concept of Polling but I need some example to understand it more properly.
Thanks In advance
The loop() function gives you the repetetive execution and a simple if can perform your test.
const byte pinToPoll = LED_BUILTIN;
void setup() {}
void loop()
{
if (digitalRead(pinToPoll)) {
// react
}
}
Sample code to poll multiple inputs
const byte buttonPins[] = {A1, A2, A3}; //buttons attached to these pins
void setup()
{
Serial.begin(115200);
for (int x = 0; x < 3; x++)
{
pinMode(buttonPins[x], INPUT_PULLUP); //set button pins as inputs
}
}
void loop()
{
for (int x = 0; x < 3; x++)
{
if (digitalRead(buttonPins[x]) == LOW)
{
Serial.print("The button on pin ");
Serial.print(buttonPins[x]);
Serial.println(" is pressed");
}
}
}
Note that I used analogue inputs in the code because that is what my test system is set up to do but the principle will work with any pins.
Thanks a lot Whandall and UKHeliBob for your help.