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.

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();
   
}
}

code: [select]
while (val=low) {
same withe while (val = high)
code: [select]
while(val == low)
will send 2 while input held low.


Arduino Forum > Using Arduino > Programming Questions > Input Pin Always Reads HIGH


arduino

Comments

Popular posts from this blog

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums

Multithumb configuration params not working? - Joomla! Forum - community, help and support