hello, i trying to understand the basics, but no.. i dont get it.
can someone explain to me why i cant get the leds to light up on pin 3 and 4?
int led1 = 0; // blink 'digital' pin 0
int led2 = 1; // blink 'digital' pin 1 - AKA the built in red LED
int led3 = 2; // blink 'digital' pin 2
int led4 = 3; // blink 'digital' pin 3
int led5 = 4; // blink 'digital' pin 4
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led1, HIGH);
delay(100);
digitalWrite(led1, LOW);
delay(100);
digitalWrite(led2, HIGH);
delay(100);
digitalWrite(led2, LOW);
delay(100);
digitalWrite(led3, HIGH);
delay(100);
digitalWrite(led3, LOW);
delay(100);
digitalWrite(led4, HIGH);
delay(100);
digitalWrite(led4, LOW);
delay(100);
digitalWrite(led5, HIGH);
delay(100);
digitalWrite(led5, LOW);
delay(100);
}
What type of Arduino board are you using ?
int led1 = 0; // blink 'digital' pin 0
int led2 = 1; // blink 'digital' pin 1 - AKA the built in red LED
int led3 = 2; // blink 'digital' pin 2
int led4 = 3; // blink 'digital' pin 3
int led5 = 4; // blink 'digital' pin 4
Is the built in LED really on pin 1 or is that one of the Serial pins, along with pin 0, that it is better not to use as digital pins ?
Do yourself a favour and if you must name LEDs like that give the variable the same number as the LED to avoid confusion, use a byte instead of an int and make the variables const. Better still, use an array of LED pins to make the code simpler.
Advice. Get the LEDs off of pins 0 and 1 and try again.
HeliBob, he says it's a Trinket, which according to the Adafruit site is based around the ATtiny85.
Thanks. I didn't realise that was the name of the board. I thought that he was building a trinket of some kind with flashing LEDs.
It looks to me that the pins are right for a Trinket... I'll try on mine when I get home.
Have you tried shifting the LEDs to other pins to verify they're not faulty? Or not backwards?
UKHeliBob:
I didn't realise that was the name of the board.
Links to datasheets or supplier sites always a good idea.....
Hi, thanks for looking into it
Yes it an Adafruit Trinket 5volt version
Trinket may be small, but do not be fooled by its size! It's a tiny microcontroller board, built around the Atmel ATtiny85, a little chip with a lot of power. We wanted to design a microcontroller board that was small enough to fit into any project,...
i have tripplechecked the LEDs switched them arount and they all work fine.
im thinking it have someting to do with the pin 3and4 are shared with the USB-interface
i cant find anything about it other than those pins are also used for programming while in bootloader.
im looking at doing an POV display proof of concept as a first sample project for my step into this world
I can't test right now, can't find the right usb cable....