Good morning,
so for many it will seem silly if not worse...
I have an Arduino Opta ETH board, I tried to "adapt" the various examples that I find here on the site and within the IDE.
One of my difficulties is transforming the addresses of the PINs, which as is known are for example pinMode(2, INPUT) etc., with OPTA the inputs go from A0 to A8, the outputs from D0 to D4.
So my difficulty is for example making a loop where the variable is inserted instead of the physical address, better said I would like something like for(i=0;i<7;i++ to have a digitalRead(Ai) or digitalWrite(Di) .
Thank you
The following works for me...
This should get you started on the digital inputs as well.
// Array of terminals.
const int cnt_inputs[] = {A0, A1, A2, A3, A4, A5, A6, A7};
const int NUM_PINS = 8;
// Array of LEDs
const int USER_LEDS[] = {LED_D0, LED_D1, LED_D2, LED_D3};
const int NUM_LEDS = 4;
void setup {
for (int i = 0; i < NUM_PINS; i++) {
pinMode(cnt_inputs[i], INPUT);
}
for (int i = 0; i < NUM_LEDS; i++) {
pinMode(USER_LEDS[i], OUTPUT);
}
}
void loop() {
for (int i = 0; i < NUM_LEDS; i++){
digitalWrite(USER_LEDS[i], HIGH);
delay(500);
}
for (int i = 0; i < NUM_LEDS; i++){
digitalWrite(USER_LEDS[i], LOW);
delay(500);
}
}
Thank you! It's what I was looking for!