Hello.
I’m trying to see if I can use the pins on the Grove to run external circuits, like push buttons and toggle switches that do not connect directly to one of the 4-pin Grove ports. Specifically, I’m trying to use the side row digital pins to detect the state of a switch and then do something, in this example - change the color of an LED (which is connected to a grove port).
I’m trying to replicate this schematic:
This is my setup:
Here’s the code:
#include <ChainableLED.h>
#define NUM_LEDS 1
ChainableLED leds(6, 7, NUM_LEDS);
void setup() {
pinMode(2, INPUT);
}
void loop() {
int p=digitalRead(2);
if(p==HIGH){
leds.setColorRGB(0,0,255,0);
}
else{
leds.setColorRGB(0,255,0,0);
}
delay(100);
}
I’ve tried using 220ohm 440ohm, 1000ohm resistors. If I connect the setup to the ground as shown in the schematic, upon switch ON, the device shuts down - I’m guessing it’s tripping the internal safeguard because the current is too high? If I don’t use the ground, the pin state just doesn’t get detected.
What am I missing? Why doesn’t this work?