Hey -
I'm using a pro mini 5v/16mhz, which is connected to a pushbutton (via 10k resistor) and one RGB LED. I tested my code initially on an Uno, and everything works as I wanted it to. I need to use the pro mini because of its small size, so I finally transferred my code to a pro mini after testing the blink schematic on it (works fine!). However, with the FTDI cable OR LiPO battery (from adafruit, 2000 mAh 3.7v) it doesn't turn on the LED at all! What's going on? I even wired two of these batteries in serial for 7.4v and still no go. Code is below. All the wires are in their proper places - I double checked the pins and all is good.
const int redPin = 12;
const int greenPin = 11;
const int bluePin = 10;
const int buttonPin = 9;`
int counter = 0;
int buttonState = 0;
int lastState = 0;
#define COMMON_ANODE
void setup() {
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(buttonPin, INPUT);
//Serial.begin(9600);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState != lastState) {
if (buttonState == HIGH) {
counter++;
//Serial.println("on");
//Serial.print("number of button pushes: ");
//Serial.println(counter);
//} else {
//Serial.println("off");
}
delay(50);
}
lastState = buttonState;
if (counter == 1) {
orange();
} else if (counter == 2) {
red();
} else if (counter == 3) {
purple();
} else {
off();
}
if (counter > 3)
counter = 0;
}
void off() {
analogWrite(redPin, 0);
analogWrite(bluePin, 0);
analogWrite(greenPin, 0);
}
void purple() {
setColor(153, 51, 255);
}
void red() {
setColor(255, 0, 0);
}
void orange() {
setColor(255, 90, 80); // orange
}
void setColor(int red, int green, int blue) {
#ifdef COMMON_ANODE
red = 255 - red;
green = 255 - green;
blue = 255 - blue;
#endif
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}