Is it possible to read the level of the input pins on the Edge control? I was able to get them to work using the example provided in IRQ Counter Example, but with using digitalRead() I'm not having any luck getting the pin to change state. Does this not work on the edge control?
#include <Arduino_EdgeControl.h>
void setup()
{
EdgeControl.begin();
Serial.begin(115200);
pinMode(IRQ_CH1, INPUT);
}
void loop()
{
// Check for received IRQ every second.
Serial.println(digitalRead(IRQ_CH1));
}
Yes, it is possible to read the level of the input pins on the Edge Control using digitalRead() function, but you have to make sure that the pin is properly configured as an input.
In your code, you are using pinMode(IRQ_CH1, INPUT) to configure the pin as an input, which is correct. However, the digitalRead(IRQ_CH1) function should return the state of the pin. If the pin is high, it should return HIGH (1), and if it is low, it should return LOW (0).
Make sure that the pin is connected to a voltage source (for example, 3.3V or 5V) or a ground through a resistor, and that the voltage level changes according to your input signal. If you are still having trouble reading the input pin, you can try using a multimeter to check the voltage level on the pin.
Also, keep in mind that the Edge Control has two different types of input pins: standard GPIO pins and low-power wake-up pins. Make sure that you are using the correct type of pin for your application. If you are using a wake-up pin, you may need to configure it differently than a standard GPIO pin.
Finally, note that the digitalRead() function may not be the fastest way to read input pins on the Edge Control, especially if you need to read them frequently. You may want to consider using direct register access or interrupts for faster response times.
When I run this program, all I get on the serial output is 1 from digitialRead(IRQ_CH1), that hasn't changed. I've tried connecting to the GND terminal on the same connector and I was using the +12V pins on that same connector for a high state reference. The +12V did work for the interrupt example.
Are there different pins on this board that would be better to use? One of the signals I'm trying to read is an input signal from a relay to tell me if a motor is running or not, for example. I thought these were my only input pins on this board to work with, but if there are other/better pins I'm not sure which ones.
It's possible that the issue you're experiencing with digitalRead(IRQ_CH1) always returning a value of 1 could be due to the way the input pin is connected or the voltage level of the input signal. Make sure that the input pin is connected to a voltage source (for example, 3.3V or 5V) or a ground through a resistor, and that the voltage level changes according to your input signal.
Regarding the input pins on the Edge Control, there are several options available depending on your requirements. In addition to the standard GPIO pins and low-power wake-up pins, the Edge Control also has several communication interfaces such as I2C, SPI, and UART that can be used to communicate with external sensors or devices.
If you're looking for a pin to use for input signals from a relay, you may want to consider using one of the standard GPIO pins, such as GPIO 0 to GPIO 5, which are available on the Edge Control's 40-pin expansion header. These pins can be configured as inputs or outputs and can be used to read or control a wide range of devices, including relays.
You can find more information about the available pins and their functionalities in the Edge Control documentation. Keep in mind that some pins may have specific functions or limitations, so be sure to check the documentation before using them.
If you're still having trouble reading the input pin, you may want to consider using an oscilloscope to check the voltage level and waveform of the input signal to make sure it is within the expected range. Additionally, you could try using an interrupt-based approach to read the input pin, which can be faster and more reliable than using digitalRead().
So something else I'm noticing with this board- with my wiring and code below (I switched to IRQ_CH4 just to make sure there wasn't an issue with CH1 but I get the same behavior, and I am using 12V because the +5V pin from the adjacent header doesn't do anything at all when connected to IRQ_CH4)....when I close the switch I get 2 counts using CHANGE for the attachInterrupt. If I use RISING, I get 1 count, if I use FALLING, I also get 1 count but it occurs when I close the switch, not when I open the switch. It seems this inputs always have a value of 1 that only changes momentarily to a 0 when first connected to a voltage source. Is that the correct behavior for these?
#include <Arduino_EdgeControl.h>
int testvar = 0;
void setup()
{
EdgeControl.begin();
Power.on(PWR_3V3);
Power.on(PWR_VBAT);
Serial.begin(115200);
pinMode(IRQ_CH4, INPUT);
attachInterrupt(digitalPinToInterrupt(IRQ_CH4), []{testvar = testvar+1;}, CHANGE);
}
void loop()
{
// Check for received IRQ every second.
Serial.println(testvar);
delay(500);
}
Where exactly are those GPIO pins? I am using the case/LCD screen with this, if you're referring to the pins the LCD screen would use. Are they accessible from one of the six 18 pin headers on the board?
Thank you for your help on this, its really appreciated. There's not much out there yet on these boards to see the issues and resolutions others have ran into.