When a switch is pressed, it should blink the appropriate LED. There is two LED functions for small and large particles passing through a photo resistor which is being bombarded with a laser.
The serial monitor should count the large and small particles.
system
April 14, 2014, 9:13pm
2
How does a single photo resistor count large and small particles?
Using an external switch.
Here is the code i did already, its not correct.
#define A0 0
#define large 9
#define small 4
#define sw 12
void smallParticleBlinkLED()
{
int swSmall = digitalRead(sw);
int sensorValue = analogRead(A0);
float smallParticleBlinkLED=sensorValue;
Serial.println(smallParticleBlinkLED);
while(swSmall == LOW)
{
if(smallParticleBlinkLED>=20.46)
{
digitalWrite(small, HIGH);
}else
{
digitalWrite(small, LOW);
}
} }
void largeParticleBlinkLED()
{
int swLarge = digitalRead(sw);
int sensorValue = analogRead(A0);
float largeParticleBlinkLED=sensorValue;
Serial.println(largeParticleBlinkLED);
while(swLarge == LOW)
{
if(largeParticleBlinkLED>=81.84)
{
digitalWrite(large, HIGH);
}else
{
digitalWrite(large, LOW);
}
} }
void setup()
{
//pinMode(9,OUTPUT);
//pinMode(4, OUTPUT);
//pinMode(12,INPUT_PULLUP);
DDRD = (1<<9 | 1<<4); //OUTPUT LED's
DDRB = (1<<4); //set INPUT switch
PORTB |= (1<<4); //pullup resistor
Serial.begin(9600); //begin serial monitor
}
void loop()
{{
largeParticleBlinkLED();
delay(1);
smallParticleBlinkLED();
delay(1);
}
}