Created Mon, 23 Nov 2015 23:31:53 +0000 by Ganky
Mon, 23 Nov 2015 23:31:53 +0000
Hi, I am trying to do a Tachometer with a ChipKIT Uno32 board. When a rotor is set between the IR LED and the reciever, it counts the RPM. I have this at the moment:
int val;
long last=0;
int stat=LOW;
int stat2;
int contar=0;
int sens=75;
int nPalas=1;
int milisegundos=500;
void setup()
{
Serial.begin(9600);
}
void loop()
{
val=analogRead(0);
if(val<sens) {
stat=LOW;
}
else {
stat=HIGH;
}
if(stat2!=stat){
contar++;
stat2=stat;
}
if(millis()-last>=milisegundos){
double rps=((double)contar/nPalas)/2.0*1000.0/milisegundos;
double rpm=((double)contar/nPalas)/2.0*60000.0/(milisegundos);
Serial.print(rps);
Serial.print(" RPS ");
Serial.print(rpm);
Serial.println(" RPM");
contar = 0;
last = millis();
}
}
I have the problem that the serial doesn't detect any signal:
I have Windows 10 (if it is important)
What can I do?
Thanks.
Tue, 24 Nov 2015 00:00:01 +0000
You're using analogRead(0) yet you have your green wire connected in to digital pin 0. Instead it should be connected to analog pin 0.
Tue, 24 Nov 2015 20:35:59 +0000
OK, I tried changing that and it works now. Thank you so much majenko!
Tue, 24 Nov 2015 20:48:02 +0000
This is one of those times that a serious problem was almost immediately and correctly solved by another user (Majenko - thanks!) just looking at a set of complete and clear pictures of the setup. Thank you for posting those! I don't know how many times people asking me questions about things not working were solved by looking at how they had things all connected.
*Brian