Teensy Tutorials dont work on teensy 3.2 board

Status
Not open for further replies.

djthopa

Member
Hi,

Thanks for an amazing hard / software.

Im currently using Arduino 1.8.5 and teensy 1.41 software.

I have started doing the tutorials on the web:

https://www.pjrc.com/teensy/td_digital.html

Many of the examples either dont compile properly, or when i try to upload to my board they dont work as expected.

Here is one from the tutorials:

void setup()
{
pinMode(PIN_D6, OUTPUT); // LED
pinMode(PIN_D7, INPUT_PULLUP); // Pushbutton
}

void loop()
{
if (digitalRead(PIN_D7)) {
// D7 pin is high due to pullup resistor
digitalWrite(PIN_D6, LOW); // LED on
delay(400); // Slow blink
digitalWrite(PIN_D6, HIGH); // LED off
delay(400);
} else {
// D7 pin is low due to pushbutton pressed
digitalWrite(PIN_D6, LOW); // LED on
delay(80); // Fast blink
digitalWrite(PIN_D6, HIGH); // LED off
delay(80);
}
}

If in Arduino i choose teensy 2.0 it debugs ok, but when uploading to teensy i tells me im choosing the wrong board:

here are the screenshots:

Screen Shot 2018-05-19 at 02.43.56.png

Screen Shot 2018-05-19 at 02.44.16.png

Screen Shot 2018-05-19 at 02.44.38.png

If i choose the right board (Teensy 3.2) and debug inside arduino i get all this error messages, but i can upload to my teensy board:

Screen Shot 2018-05-19 at 02.47.23.png

Screen Shot 2018-05-19 at 02.47.45.png

Specially im having trouble with having to define the outs of the boards like

int Led1 = 0;
int Led2 = 1;
int Led3 = 2;

pinMode(Led1, OUTPUT);
pinMode(Led2, OUTPUT);

Also having problems with timers

void setup()
{
pinMode(PIN_D6, OUTPUT); // LED
pinMode(PIN_D7, INPUT_PULLUP); // Pushbutton
}

void loop()
{
if (digitalRead(PIN_D7)) {
// D7 pin is high due to pullup resistor
digitalWrite(PIN_D6, LOW); // LED on
delay(400); // Slow blink
digitalWrite(PIN_D6, HIGH); // LED off
delay(400);
} else {
// D7 pin is low due to pushbutton pressed
digitalWrite(PIN_D6, LOW); // LED on
delay(80); // Fast blink
digitalWrite(PIN_D6, HIGH); // LED off
delay(80);
}
}

In this example when changing the ports to match the ones on the teensy 3.2, pushbutton does not reduce the speed of the blinking light like it should.

Here is my code so it works and uploads to teensy 3.2 board


void setup(){


int Led1 = 0; // Port for led 1
int pushbutton1 = 14; // Port for push button on pin 14

pinMode(Led1, OUTPUT); // LED
pinMode(pushbutton1, INPUT_PULLUP); // Pushbutton
}

void loop()
{
int Led1 = 0; // Port for led 1
int pushbutton1 = 14; // Port for push button on pin 14

if (digitalRead(pushbutton1)) {
// pushbutton1 pin is high due to pullup resistor
digitalWrite(Led1, LOW); // LED on
delay(400); // Slow blink
digitalWrite(Led1, HIGH); // LED off
delay(400);
} else {
// pushbutton1 pin is low due to pushbutton pressed
digitalWrite(Led1, LOW); // LED on
delay(80); // Fast blink
digitalWrite(Led1, HIGH); // LED off
delay(80);
} }

So without pressing the pushbutton1 led blinks normally but does not blink more slow when pressed.

Im concerned im doing something wrong and would like to know before i keep on trying the tutorials and getting to the synthesis models.

Hope someone can point me out in the right direction.

Cheers
 
Also, probably supernoob question but seems like i have to define Led1 and pushbutton1 inside void loop or it gives me the error that they have not been declared.
 
Ok, my bad, i had the pushbutton1 connected to the positive rail, now the blinking timer works.

What i still dont get is the error with port definitions.

Cheers
 
Oh, a miracle! You got old example code which was written for the old and obsolete 8bit Teensy1 processors partly running on a modern 32bit Teensy 3.x processor...

When looking for example code, you should rather not take it from the PJRC website which is not always up to date since Paul puts more time into helping users and creating new products. Actual and adapted examples come always with the current Teensyduino version. You can find these in the Arduino IDE under File - Examples - Teensy
 
Oh, a miracle! You got old example code which was written for the old and obsolete 8bit Teensy1 processors partly running on a modern 32bit Teensy 3.x processor...

When looking for example code, you should rather not take it from the PJRC website which is not always up to date since Paul puts more time into helping users and creating new products. Actual and adapted examples come always with the current Teensyduino version. You can find these in the Arduino IDE under File - Examples - Teensy

Thanks! Just tried to start from the beginning and those are the tutorials i found first. Thought it made sense to start from there and after move to the other included tutorials.

Thanks for your input and info.

Regards
 
Status
Not open for further replies.
Back
Top