Pages: 1 [2]   Go Down
Author Topic: RFID and LEDs - Help with code?  (Read 1106 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.


Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 640
Posts: 50331
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 640
Posts: 50331
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: 1 [2]   Go Up
Jump to: