Go Down

Topic: RFID and LEDs - Help with code? (Read 1 time) previous topic - next topic

ch_91

Thanks.

I can get the LED to turn red no problem - or any other colour for that matter. It becomes a problem when RFID comes into the equation. I'll have a look at the functions you said.

Thank you.

ch_91

I think I should be banned from Arduino and anything to do with code.

I can't even get the Arduino to select red or blue at random through the RGB LED.



PaulS

Quote
I think I should be banned from Arduino and anything to do with code.

If you won't post your code, I agree.

If you do post it, then, at least you're trying.

ch_91

Haa.

I'm trying to do what you said and just take it a one step at a time rather than jumping into the deep end of RFID'ing all at once.

Code: [Select]
int redLed = 11;
int greenLed = 10;
int blueLed = 9;

long randNumb;;

void setup()
{
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(blueLed, OUTPUT);
randomSeed(analogRead(0));
}

void red()
{
analogWrite(redLed, 255);
analogWrite(greenLed, 0);
analogWrite(blueLed, 0);  
}  

void green()
{
analogWrite(redLed, 0);
analogWrite(greenLed, 255);
analogWrite(blueLed, 0);  
}  

void blue()
{
analogWrite(redLed, 0);
analogWrite(greenLed, 0);
analogWrite(blueLed, 255);  
}  

void loop()
{
randNumb = random(1, 4);

if(randNumb == 1){
 red();
}  
if(randNumb == 2){
 green();
}
if(randNumb == 3){
 blue();
}
}


Thanks.

PaulS

How long with each color be on? Not very long, as I read your code. Try, for the moment, adding a delay(250); to loop(), at the end.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy