Hi All;
I am currently working on a project development, which involves sensor fusion of IMU and Force sensors, but there is also a reset button(pushbutton) involved for recalibration purpose. Initially we used Arduino pro mini for its form factor but faced certain issues with speed and memory due to which we had to switch our controller to Teensy3.2. I have installed the latest version of Teensyduino 1.42 and I am using Arduino IDE version 1.8.5
While using teensy 3.2 I am currently facing an issue in reading Pushbutton states (HIGH or LOW) using the digitalRead arduino command. The circuit which I used to read a pushbutton in arduino pro mini is unaltered and it worked fine with Atmega328p 5V 8Mhz version. But using teensy 3.2 the button value is always zero. I post the test code below.
///////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
The circuit is connected in a way that one end of button goes to 3.3V power pin, other end is connected to a pulldown resistor 10K which is grounded. The MCU readpin D14 is connected to node where the button connects the resistor.
Technically the (buttonVal) should read 1 when the switch is pressed, But it never reads 1. It is always zero.
Please let me know if I am going wrong in any part, May be there can be some silly mistake.
Thanks in advance
I am currently working on a project development, which involves sensor fusion of IMU and Force sensors, but there is also a reset button(pushbutton) involved for recalibration purpose. Initially we used Arduino pro mini for its form factor but faced certain issues with speed and memory due to which we had to switch our controller to Teensy3.2. I have installed the latest version of Teensyduino 1.42 and I am using Arduino IDE version 1.8.5
While using teensy 3.2 I am currently facing an issue in reading Pushbutton states (HIGH or LOW) using the digitalRead arduino command. The circuit which I used to read a pushbutton in arduino pro mini is unaltered and it worked fine with Atmega328p 5V 8Mhz version. But using teensy 3.2 the button value is always zero. I post the test code below.
///////////////////////////////////////////////////////////////////////
Code:
const int buttonPin = 14; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
int buttonVal = 0; // variable for reading the pushbutton status
int LstBtnVal = 0;
int BtnCnt = 0;
void setup() {
// initialize the LED pin as an output:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB.
}
Serial.println("Starting Code");
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop() {
// read the state of the pushbutton value:
buttonVal = digitalRead(buttonPin);
if (LstBtnVal>buttonVal){
BtnCnt = BtnCnt+1;
}
Serial.print(buttonVal);
Serial.print(" ");
Serial.println(BtnCnt);
LstBtnVal = buttonVal;
delay(50);
}
The circuit is connected in a way that one end of button goes to 3.3V power pin, other end is connected to a pulldown resistor 10K which is grounded. The MCU readpin D14 is connected to node where the button connects the resistor.
Technically the (buttonVal) should read 1 when the switch is pressed, But it never reads 1. It is always zero.
Please let me know if I am going wrong in any part, May be there can be some silly mistake.
Thanks in advance
Last edited: