I'm trying to connect a switch to the A6 pin, but when I try to read the pin status, I always get the '0' signal.
When I use the analogRead method, it gives 1023, and when measuring the pin voltage, it gets the 5V or 0V's
What's my mistake? (btw, I'm using this analog pin because all the digital ones are already in use...)
With the code below, I'm just trying to show the pinstatus.
I'm using an external pullup resistor (10k)
#include <Wire.h>
#include <LiquidCrystal.h>
int lcdOut = A3;
int lcdRS = 4;
int lcdEnable = 5;
int lcdD4 = 6;
int lcdD5 = 7;
int lcdD6 = 8;
int lcdD7 = 12;
LiquidCrystal lcd(lcdRS, lcdEnable, lcdD4, lcdD5, lcdD6, lcdD7);
void setup()
{
Wire.begin();
Serial.begin(9600);
pinMode(lcdOut,OUTPUT);
digitalWrite(lcdOut,LOW);
lcd.begin(16,2);
Serial.println("wachten");
delay(1000);
Serial.println("ok");
digitalWrite(lcdOut,HIGH);
delay(100);
lcd.display();
pinMode(A6,INPUT);
digitalWrite(A6, HIGH);
}
void loop()
{
lcd.print(analogRead(A6));
lcd.print(" ");
lcd.print(digitalRead(A6));
Serial.println(analogRead(A6));
Serial.println(digitalRead(A6));
delay(10);
lcd.clear();
}
Ohw, with that information, the gray 'digital pins' on the pinout diagram are explained...
Its quiet easy to work around I guess, just if(analogRead>512) instead of digitalRead(..) will work in my case.
Thanks for pointing it out.