Hi! Can some one help me with Arduino codes for converting analog signal to digital signal.
There four input analog signal wishing to convert each them to digital signal.
Hi! Can some one help me with Arduino codes for converting analog signal to digital signal.
There four input analog signal wishing to convert each them to digital signal.
what is your required sampling rate and resolution, also do you know the signal voltage range of the analog input is?
If you need more information about the analog inputs of the arduino look at:
http://arduino.cc/en/Tutorial/AnalogInputPins
The analogRead instruction is described here:
http://arduino.cc/en/Reference/AnalogRead
When you have your arduino IDE installed look in the examples, analog section
heliosoph
Thanx alot I have tried to code but I when I try to run my codes I encounter an error,so can any one help me to solve this issue.
int inputPins[] = {2,3,4,5}; // create an array of pins for inputs
int lcdPins[] = {0,1,2,3,4,5,6,7}; // create array of output pins for LEDs
void setup()
{
for(int index = 0; index < 3; index++)
{
pinMode(inputPins[index], INPUT); // declare inputpins
}
}
void loop(){
for(int index = 0; index < 4; index++)
{
analogRead(inputPins[index]); // read input val
}
float val0=analogRead(inputPins[0]);
float val1=analogRead(inputPins[1]);
float val2=analogRead(inputPins[2]);
float val3=analogRead(inputPins[3]);
if(val0 >=0.2){
digitalWrite( val0,HIGH);
}
else if (val1>= 1.5){
digitalWrite( val1,HIGH);
}
else if (val2>val 3){
digitalWrite(val2,HIGH);
}
else
digitalWrite( val0,LOW );
digitalWrite( val1,LOW );
digitalWrite( val2,LOW );
if (val0==LOW && val1==LOW && val2==LOW){
Serial.println("Blood group O-");
}
else if (val0==LOW && val1==LOW && val2==HIGH){
Serial.println("Blood group O+");
}
else if (val0==LOW && val1==HIGH && val2==LOW){
Serial.println("Blood group B- ");
}
else if (val0==LOW && val1==HIGH && val2==HIGH){
Serial.println("Blood group B+");
}
else if (val0==HIGH && val1==LOW && val2==LOW){
Serial.println("Blood group A-");
}
else if (val0==HIGH && val1==LOW && val2==HIGH){
Serial.println("Blood group A+");
}
else if (val0==HIGH && val1==HIGH && val2==LOW){
Serial.println("Blood group AB-");
}
else if (val0==HIGH && val1==HIGH && val2==HIGH){
Serial.println("Blood group AB+");
}
}
Hi Francis,
This video explains every thing you need https://www.youtube.com/watch?v=js4TK0U848I&index=5&list=SPA567CE235D39FA84
Here is another one https://www.youtube.com/watch?v=y-_Pkw_GQ-c
Best of luck..
Hello Francis,
you have only a little typo in your code:
else if (val2>val 3){ digitalWrite(val2,HIGH); }
The space in "val 3" must be deleted:
else if (val2>val3){ digitalWrite(val2,HIGH); }
This should work. :-)
thanx for ur concern
I think you have a mess with your variables:
digitalWrite( val0,HIGH);
val is your variable where you store your values from analogRead. In digitalWrite() you have to use a (digital) pin number. The pin you want to set to high.
Elektrix
First off, I don't see why you are using analogRead(), unless your switches in your schematic are just representations of something that outputs an actual analog signal - You are not reading Analog. Your pins will see either LOW (switch close) or HIGH, assuming the internal pullups are set. So why not use Digital pins for this?
My switches in my schematic are just representations of something that outputs analog signal,I have set threshold value for each pin