Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int sum = 0;
- void setup() {
- // initialize serial communication at 9600 bits per second:
- Serial.begin(9600);
- pinMode(7, OUTPUT);
- digitalWrite(7, LOW);
- }
- // the loop routine runs over and over again forever:
- void loop() {
- for (int i = 0; i <= 10; i++) {
- int sensorValue = analogRead(A0);
- sum = sum + sensorValue;
- }
- if (sum <= 3) {
- digitalWrite(7, HIGH);
- Serial.println(sum);
- delay(2);
- sum = 0;
- }
- else {
- digitalWrite(7, LOW);
- Serial.println(sum);
- sum = 0;
- }
- delay(1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement