teensy 2.0 and teensy 3.0 question

Status
Not open for further replies.

dani190

Member
Hello, was wondering is there any way to make the Teensy load the code it has on it upon boot?

I find that when i turn the power on my script does not run. I know this because my LCD's are not showing anything when they should be. If i plug the usb in and hit reboot on the teensyloader program, it then works.

I know Teensy 3.0 has a pin i can just trigger to do this but the Teensy 2.0 does not from what i read.
 
This is not the behavior I see. I see that when I plugin the teensy my code runs. I suspect something else is going on. Maybe some timing thing? Can you blink the LED or something to verify that your code is running?
 
Teensy always runs your program when it powers up.

Perhaps your code has something that depends on the PC responding? Could your post your code, or a small/simple program which demonstrates the problem? Also, it matter which option you've selected from Tools > USB Type, which isn't in your message, so please let us know that too?
 
The code on my teensy 2.0 is as follows

HardwareSerial Uart = HardwareSerial();

void setup()
{
Uart.begin(9600);
}

void loop()
{
shiftLeft();
}

void shiftLeft()
{
Uart.print("Welcome to Centennial College - ICET");
while(1)
{
Uart.write(0xFE);
Uart.write(0x55);
delay(350);
}
}


As for tools > USB Type is set as serial
 
I'm running it right now on a Teensy 2.0, powered from a 5V power supply (no USB connection). It's sending those 2 bytes on pin 8 every 350 ms.

I've switched the power off and back on several times. Every time it starts up and sends those bytes.
 
I'm running it right now on a Teensy 2.0, powered from a 5V power supply (no USB connection). It's sending those 2 bytes on pin 8 every 350 ms.

I've switched the power off and back on several times. Every time it starts up and sends those bytes.

My exact setup has an LCD connected to the TX pin and it turns on at the same time with the Teensy 2.0 using the same power supply.

Any ideas what could be wrong?
 
I have no idea.

As a first step, you might change your code to something like this:

Code:
pinMode(11, OUTPUT);
while(1) {
  digitalWrite(11, HIGH);  // LED on
  Uart.write(0xFE);
  Uart.write(0x55);
  delay(350);
  digitalWrite(11, LOW);  // LED off
  Uart.write(0xFE);
  Uart.write(0x55);
  delay(350);
}

Then you'll at least be able to see if the LED changes, to know if your program is running.

Maybe the LCD isn't starting up properly?
 
Last edited:
I have no idea.

As a first step, you might change your code to something like this:

Code:
pinMode(11, OUTPUT);
while(1) {
  digitalWrite(11, HIGH);  // LED on
  Uart.write(0xFE);
  Uart.write(0x55);
  delay(350);
  digitalWrite(11, LOW);  // LED off
  Uart.write(0xFE);
  Uart.write(0x55);
  delay(350);
}

Then you'll at least be able to see if the LED changes, to know if your program is running.

Maybe the LCD isn't starting up properly?

Thanks Paul, that worked and i just modified my code a bit further. By adding a delay to the actual start of the code that allowed the LCD to start fully and then start the code.

My code now looks like

Code:
HardwareSerial Uart = HardwareSerial();
void setup()
{
  Uart.begin(9600);
  pinMode(11, OUTPUT);
  delay(100);
}

void loop()
{
  shiftLeft();
}

void shiftLeft()
{
  Uart.print("Welcome to Centennial College - ICET");
  while(1) {
    digitalWrite(11, HIGH);  // LED on
    Uart.write(0xFE);
    Uart.write(0x55);
    delay(350);
    digitalWrite(11, LOW);  // LED off
    Uart.write(0xFE);
    Uart.write(0x55);
    delay(350);
  }
}

Just incase anyone was wondering.

Thanks again for the help!
 
Status
Not open for further replies.
Back
Top