Analogue pins on the Arduino Nano/Uno (ATmega 328) can be configured as Digital GPIO pins using the Arduino IDE commands 'DigitalRead' and 'DigitalWrite' - is there an equivalent in GCB ? I could use a few more Digital pins in a project, and am not using any Analogue pins.
I've checked through the documentation but can't see anything obvious - if the answer is in there and I've missed it - apologises.
Last edit: Colin Powell 2018-12-19
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
GCBASIC should be able to set the pin modes automatically. All pins are set to digital inputs by default, and are only set to analog temporarily when an analog reading is taken using ReadAD (or similar). The pin will be configured as an output if you write to it. If the compiler can't work out what to do, it will show a warning and you'll have to add a Dir command to set the mode.
If you're using the library for the Uno (uno_mega328p.h), then the analog pins are already defined as ANALOG_0 to ANALOG_5. To turn them on and off, use Set. To generate a pulse, use Pulseout. For example, to drive analog 1 high, use Set ANALOG_1 On, or if you prefer ANALOG_1 = 1.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Analogue pins on the Arduino Nano/Uno (ATmega 328) can be configured as Digital GPIO pins using the Arduino IDE commands 'DigitalRead' and 'DigitalWrite' - is there an equivalent in GCB ? I could use a few more Digital pins in a project, and am not using any Analogue pins.
I've checked through the documentation but can't see anything obvious - if the answer is in there and I've missed it - apologises.
Last edit: Colin Powell 2018-12-19
You can set any port as digital input/output... (not VCC or VDD. The concept of 'DigitalRead'and 'DigitalWrite' is purely an Ardunio usage constraint.
Just use DIR port.x IN | OUT
GCBASIC should be able to set the pin modes automatically. All pins are set to digital inputs by default, and are only set to analog temporarily when an analog reading is taken using ReadAD (or similar). The pin will be configured as an output if you write to it. If the compiler can't work out what to do, it will show a warning and you'll have to add a Dir command to set the mode.
If you're using the library for the Uno (uno_mega328p.h), then the analog pins are already defined as ANALOG_0 to ANALOG_5. To turn them on and off, use Set. To generate a pulse, use Pulseout. For example, to drive analog 1 high, use Set ANALOG_1 On, or if you prefer ANALOG_1 = 1.
Brilliant - thank you.