Problem with reading digital pins.
Well i got a few E18-D80NK infrared sensors ( sensors operates on 5v ). that trigers low A pulse on detection.
It works fine with an Arduino Uno (sensors work), I adjusted the sketch for the Proto board with a 32U4
And made some text display output instead of led outputs.
But although i can set ports by connecting them to +5v output or ground, its not working with the sensors.
Does the Proto board also require the Indio library. ? (the website tells it doesnt).
My sketch roughly looks like below ( i removed some of our project related parts)
#include <UC1701.h>
static UC1701 lcd;
bool tracked = false;
int Asensor = 4; // since it didnt work i made this code more flexible so its more easy to change to other ports.
int Bsensor = 6;
void setup()
{
// at 9600 baud it takes about 960 bytes p seccond ea 0.001ms p character
Serial.begin(9600); //Start serial communication boud rate at 9600
pinMode(Asensor,INPUT); //Pin 4 as signal input sets
pinMode(Bsensor,INPUT); //Pin 6 as signal input
lcd.begin();
}
void loop()
{
// both arrays below are for visual output
String pins [21] ={"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20" };
String KnightRider[13] = {
" x",
" xx ",
" xxx ",
" xxx ",
" xxxx ",
" xxxxx ",
" xxxxx ",
" xxxx ",
" xxxx ",
" xxx ",
" xxx ",
" xx ",
"x ",
};
digitalWrite(13,0); //turns the light on of the display it seams
int effect =0;
int effectSign = +1;
int dummycounter;
while(true)
{
dummycounter++;
if (dummycounter%5==0)effect = effect +effectSign;
{
if (effect ==12) effectSign=-1;
if (effect ==0) effectSign = 1;
lcd.setCursor(0, 2);
lcd.print(KnightRider[effect]); // simple effect to show the code is running, not halting or so.
lcd.setCursor(1, 3);
String sensA ;
String sensB ;
if (digitalRead(Asensor)==LOW)sensA="Low";else sensA = "High";
if (digitalRead(Bsensor)==LOW)sensB="Low";else sensB = "High";
String digstatus ;
digstatus= "A-Pin("+pins[Asensor]+") = " + sensA +" " ;
lcd.setCursor(1, 3);lcd.println(digstatus);
digstatus = "B-Pin("+pins[Bsensor]+") = " +sensB+ " ";
lcd.setCursor(1, 4);lcd.print (digstatus);
}
}
}
Your answer
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
Keep Informed
About This Forum
This community is for professionals and enthusiasts of our products and services.
Read GuidelinesQuestion tools
Stats
Asked: 9/7/17, 7:17 AM |
Seen: 2607 times |
Last updated: 9/7/17, 9:27 AM |