digitalWrite only works for four pins on my Teensy 3.2 board.

Status
Not open for further replies.

alexdr5398

New member
Hello, I'm trying to get PWM output to work on 3 pins on my board. It wasn't working so I checked to see if digital write works on those pins and they did not. I ran the code below and discovered that it was only setting pins 12, 13, 14 and 15 to on my Teensy 3.2.

void setup() {
for (int i=0; i<24; i++)
pinMode(i, OUTPUT);
}

void loop()
{

for (int i=0; i<24; i++)
digitalWrite(i, HIGH);

while(1);
}

Is there any reason why PWM and digital output doesn't work for these pins (other than it's broken).
 
It might help to see your setup. How are you testing? Plugged into a breadboard? Anything else connected?

If you used a breadboard, did you buy a T3.2 with the pins pre-soldered in? Or did you solder them in yourself? Note: trying to use friction to make connections never works... That is there have been several people with similar sounding issues, who
simply plugged in the pins to the breadboard and slipped the T3.x onto those pins without soldering.

I keep around a simple program that helps me verify at times, I am connected up to the right pin...
Nothing special, it starts off blinking pin 13. It allows you to type in a number for the next pin you wish to try. It then sets pin 13 as input.

So if you then jumper whatever pin you typed in to pin 13 it should start blinking the LED (which is connected to pin 13...)... Again nothing special.
Code:
int current_pin = 13;
int next_pin_number = 0;
#define DBGSerial Serial
void setup() {
    // Blink any pin.  Note: I put pin 13 as input to see if we can
  // jumper to it to see if we can find the pin...
  while (!Serial && millis() < 5000);
  DBGSerial.begin(115200);
  delay (250);
  DBGSerial.println("Find Pin by blinking");
  DBGSerial.println("Enter pin number to blink"); 
  pinMode(13, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (DBGSerial.available()) {
    int ch;
    while ((ch = DBGSerial.read()) != -1) {
      if ((ch >='0') && (ch <= '9')) {
        next_pin_number = next_pin_number * 10 + (ch-'0');
      } else {
        if (next_pin_number != 0) {
          digitalWrite(current_pin, LOW); // turn the previous pin to low...
          current_pin = next_pin_number;
          pinMode(current_pin, OUTPUT);
          if (current_pin != 13)
            pinMode(13, INPUT);
          digitalWrite(current_pin, HIGH);
          next_pin_number = 0;  // setup to enter next pin
          DBGSerial.printf("Now Blinking pin %d\n\r", current_pin);
        }
      }
    }
  } else {
    digitalWrite(current_pin, !digitalRead(current_pin));
    delay(250);
  }  
}

But I have used it to verify that some IO pins work or maybe I was off by one or maybe I had a cold solder...
 
I ran your program here on a Teensy 3.2, with LEDs connected to pins 1, 2, 3. They definitely do light up, showing those pins are indeed driving logic high.

DSC_0497_web.jpg
 
Status
Not open for further replies.
Back
Top