Go Down

Topic: Inputs don't seem to work (Read 474 times) previous topic - next topic

clardae2

Code attached below.
I have tried inputs wired up with 5V and 3.3V supply from board, through switch or pushbutton (SW or PB in the code) and into assigned pins.
.
I have tried seeking the input as HIGH or LOW, and as 0 or <0.
I'm not sure what I'm doing wrong.
Have googled and read forums.
Electrically, with multimeter, the switches are working.

I want to know how to get an input IN!!

jdelcamp11

In your loop you don't have any digitalRead and analogRead steps.

Just a comment: pins 0 & 1 are used for serial TX an RX on most arduino boards. So using them for IO would interfere with your usb communication. You can use the A0 - A5 for digital IO also.
On the 101 they may be serial1 so that may not be an issue.

clardae2

I'm not using 0 & 1 just yet, but the only USB coms I have is when I dump a new program.

I modified code, it's attached. Made a few tweaks on some other stuff but if I can't get inputs, not much use in proceeding.

I tried:
 if (digitalRead(PGSW) == 0)

I tried:
int SHUTDOWN
 if (digitalRead(SHUTDOWN) == 0)

I tried:
 if (digitalRead(PGSW) == LOW)

I am getting 0VDC on the pin from my switch, where I get ~1.7VDC on a HIGH (fed from the 3.3VDC pin)

Is it because I have INPUT_PULLUP? I'm nervous to fry the board if I don't have it.
Anything else obvious?
I feel like such a rookie.

Coding Badly


@clardae2, please do not cross-post.  Other thread removed.


clardae2


jdelcamp11

Let's try to get you reading the switch position
Code: [Select]
/*
 * Lets build it one step at a time
 * This just reads the switch poistion
 * and outputs it to the serial monitor
 * so you can see if you are getting the inputs
 * that you think you have
 */

#define EGLED 0
#define NFLED 1
#define TCLED 2
#define PGLED 3

#define DIAL 6
#define BUZZ 7

#define EGPB 10
#define NFPB 9
#define TCSW 11
#define PGSW 12

void setup() {
  Serial.begin(38400);
  while (!Serial) { ; } // wait for seial connection (about 5 sec)
  Serial.println("starting");
 
  pinMode(NFPB, INPUT_PULLUP);   // PB for neutronize the field
  pinMode(EGPB, INPUT_PULLUP);   // PB for set the entry grid
  pinMode(TCSW, INPUT_PULLUP);   // switch to clean trap
  pinMode(PGSW, INPUT_PULLUP);   // switch to shutoff protection grid
  pinMode(LED_BUILTIN, OUTPUT);  // left to verify coms to PC, that new program downloaded successfully

}

void loop() {
  Serial.print("NFPB "); Serial.println( digitalRead(NFPB));
  Serial.print("EGPB "); Serial.println( digitalRead(EGPB));
  Serial.print("PGSW "); Serial.println( digitalRead(PGSW));
  delay(500); 
}

Go Up