Input Pin Always Reads HIGH
i have written code change display depending on goes input pin. however, no matter input (have tried 5 v, left empty, , gnd), display shows 5 (the sign high).
any given appreciated.
any given appreciated.
code: [select]
#include <wire.h> // enable line if using arduino uno, mega, etc.
//#include <tinywirem.h> // enable line if using adafruit trinket, gemma, etc.
#include "adafruit_ledbackpack.h"
#include "adafruit_gfx.h"
int inpin=12;
int val=0;
int time=0;
// if input low, start timer
adafruit_7segment matrix = adafruit_7segment();
void setup()
{ pinmode(inpin, input);
#ifndef __avr_attiny85__
serial.begin(9600);
serial.println("7 segment backpack test");
#endif
matrix.begin(0x70);
}
void loop() {
val=digitalread(inpin);
while (val=low) {
matrix.println(2);
matrix.writedisplay();
}
while (val=high) {
matrix.println(5);
matrix.writedisplay();
}
}
Arduino Forum > Using Arduino > Programming Questions > Input Pin Always Reads HIGH
arduino
Comments
Post a Comment