Group,
I have ported a working sketch from Arduino to Teensy 3.0. All of it works beautifully except when I try to get a PWM output from a pin. It seems I am behind the times because this simple code does nothing on the pin when I try to analog write to it. I am running Beta11 on Ubuntu 12.04. My code is pretty complicated, but if I can get this simple sketch working, I think I can get this put into the code... I will need a digitalWrite and a PWM on the pin for the sketch to function correctly.
adapted from the statechange example. If I do this, the pin will flop from high to low:
if I change the last line to:
The pin stays at LOW and nothing happens.
Thanks,
Keith
I have ported a working sketch from Arduino to Teensy 3.0. All of it works beautifully except when I try to get a PWM output from a pin. It seems I am behind the times because this simple code does nothing on the pin when I try to analog write to it. I am running Beta11 on Ubuntu 12.04. My code is pretty complicated, but if I can get this simple sketch working, I think I can get this put into the code... I will need a digitalWrite and a PWM on the pin for the sketch to function correctly.
adapted from the statechange example. If I do this, the pin will flop from high to low:
Code:
#include <Bounce.h>
#define BUTTON 0
#define LED 13
#define pwm_output 8
int ledValue = LOW;
int pwmValue = 100;
// This example changes the state of the LED everytime the button is pushed
// Build the circuit indicated here: http://arduino.cc/en/Tutorial/Button
Bounce bouncer = Bounce( BUTTON, 15 );
void setup() {
pinMode(BUTTON,INPUT);
pinMode(LED,OUTPUT);
pinMode(pwm_output, OUTPUT);
}
void loop() {
if ( bouncer.update() ) {
if ( bouncer.read() == HIGH) {
if ( ledValue == LOW ) {
ledValue = HIGH;
pwmValue = 100;
} else {
ledValue = LOW;
pwmValue = 5;
}
digitalWrite(LED,ledValue);
digitalWrite(pwm_output, ledValue);
}
}
}
if I change the last line to:
Code:
analogWrite(pwm_output, pwmValue);
The pin stays at LOW and nothing happens.
Thanks,
Keith