Teensy LED Test Problem

Status
Not open for further replies.

linuxguy

New member
Hi,
I am getting started with Teensy 3.0 . I have this program loaded to teensy :

Code:
int redPin =  23;
int greenPin =  22;
int testPin = 21;
int bluePin =  20;

// The setup() method runs once, when the sketch starts

void setup()   {                
  // initialize the digitals pin as an outputs
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
  pinMode(testPin, OUTPUT);
  
}

// the loop() method runs over and over again,

void loop()                     
{
  digitalWrite(redPin, HIGH);
  delay(500);
  digitalWrite(greenPin, HIGH);
  delay(500);
  digitalWrite(bluePin, HIGH);
  delay(500);
  digitalWrite(testPin, HIGH);
  delay(500);
  digitalWrite(redPin, LOW);
  delay(500);
  digitalWrite(greenPin, LOW);
  delay(500);
  digitalWrite(bluePin, LOW);
  delay(500);
}

When I run the application, only LED on pin 23 and 22 work , 20 and 21 don't blink at all , Could be problem with teensy or it's pins ?

Please advise .

Thank you
 
Hi,
I am getting started with Teensy 3.0 . I have this program loaded to teensy :

When I run the application, only LED on pin 23 and 22 work , 20 and 21 don't blink at all , Could be problem with teensy or it's pins ?

Please advise .

Thank you

Here... Try this, I ran it just today with a single RGB LED on Pins 21,22,23
Pin 13 is the Built-in Teensy yellow LED

Code:
/* RGB Analog Example, Teensyduino Tutorial #2
   http://www.pjrc.com/teensy/tutorial2.html

   This example code is in the public domain.
*/

const int ledPin = 13;   // Teensy 3.0 has LED on 13
const int redPin =  21;
const int greenPin =  22;
const int bluePin =  23;
int x=0;

void setup()   {                
  pinMode(ledPin, OUTPUT);
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
}

void loop()  {
  
/* 8 Bits   0 = to 255 */
  analogWriteResolution(8); 

  for(x=255; x>0; x--) {
  analogWrite(redPin, x);
  analogWrite(greenPin, x);
  analogWrite(bluePin, x);
  delay(78); 
  }
  
  analogWrite(redPin, 1);
  analogWrite(greenPin, 1);
  analogWrite(bluePin, 1);
  delay(5000);
  digitalWrite(ledPin, HIGH);   // set the LED on
  delay(100);                   // wait for a second
  digitalWrite(ledPin, LOW);    // set the LED off
  
/* 12 Bits   0 = to 4095 */
  analogWriteResolution(12); 

  for(x=4095; x>0; x--) {
  analogWrite(redPin, x);
  analogWrite(greenPin, x);
  analogWrite(bluePin, x);
  delay(4); 
  }
  
  analogWrite(redPin, 1);
  analogWrite(greenPin, 1);
  analogWrite(bluePin, 1);
  delay(5000);
  digitalWrite(ledPin, HIGH);   // set the LED on
  delay(100);                  // wait for a second
  digitalWrite(ledPin, LOW);    // set the LED off
  
  
  /* RED - YELLOW */
  for(x=0; x<4096; x++) {
  analogWrite(redPin, 4095);
  analogWrite(greenPin, x);
  analogWrite(bluePin, 0);
  delay(1); 
  }
  
 /* YELLOW - GREEN */
  for(x=4095; x>=0; x--) {
  analogWrite(redPin, x);
  analogWrite(greenPin, 4095);
  analogWrite(bluePin, 0);
  delay(1); 
  } 
  
  /* GREEN - CYAN */
  for(x=0; x<4096; x++) {
  analogWrite(redPin, 0);
  analogWrite(greenPin, 4095);
  analogWrite(bluePin, x);
  delay(1); 
  }
  
/* CYAN - BLUE */
  for(x=4095; x>=0; x--) {
  analogWrite(redPin, 0);
  analogWrite(greenPin, x);
  analogWrite(bluePin, 4095);
  delay(1); 
  }
    
 /* BLUE - MAGENTA */
  for(x=0; x<4096; x++) {
  analogWrite(redPin, x);
  analogWrite(greenPin, 0);
  analogWrite(bluePin, 4095);
  delay(1); 
  }
  
  /* MAGENTA - RED */
  for(x=4095; x>=0; x--) {
  analogWrite(redPin, 4095);
  analogWrite(greenPin, 0);
  analogWrite(bluePin, x);
  delay(1); 
  }
  
  analogWrite(redPin, 0);
  analogWrite(greenPin, 0);
  analogWrite(bluePin, 0);
  for(x=0; x<11; x++) {
  digitalWrite(ledPin, HIGH);   // set the LED on
  delay(50);                  // wait for a second
  digitalWrite(ledPin, LOW);    // set the LED off
  delay(100);
    } 
 }

Bob W.
 
Hi,
Thank you for the response. Thank you for your code too..It was my soldering that was loose, now i got it working.

Thank you Very much !

Linux Guy
 
Your welcome...
I modified the tutorial code, to look at the difference between 8 bit and 12 bit PWMs on the RGB output.... it's really only noticeable at the very low end.
Notice that I freeze it for 5 seconds with 1 bit of PWM resolution... you can only tell that its on at 12 bits in a very dark room.
 
Thanks !

Actually I dont have the RGB LED yet, i am still waiting , i just have plain leds so just testing out with uni-color leds.

Thank you , i will try your code !
 
Status
Not open for further replies.
Back
Top