I have code for Air Quality Sensor (http://www.seeedstudio.com/wiki/Grove_-_Air_Quality_Sensor) Code: /* AirQuality Demo V1.0. connect to A1 to start testing. it will needs about 20s to start * By: [URL='http://www.seeedstudio.com/']http://www.seeedstudio.com[/URL] */ #include "AirQuality.h" #include "Arduino.h" AirQuality airqualitysensor; int current_quality =-1; void setup() { Serial.begin(9600); airqualitysensor.init(14); } void loop() { current_quality=airqualitysensor.slope(); if (current_quality >= 0)// if a valid data returned. { if (current_quality==0) Serial.println("High pollution! Force signal active"); else if (current_quality==1) Serial.println("High pollution!"); else if (current_quality==2) Serial.println("Low pollution!"); else if (current_quality ==3) Serial.println("Fresh air"); } } ISR(TIMER2_OVF_vect) { if(airqualitysensor.counter==122)//set 2 seconds as a detected duty { airqualitysensor.last_vol=airqualitysensor.first_vol; airqualitysensor.first_vol=analogRead(A0); airqualitysensor.counter=0; airqualitysensor.timer_index=1; PORTB=PORTB^0x20; } else { airqualitysensor.counter++; } } How avoid (ISR(TIMER2_OVF_vect) and PORTB=PORTB^0x20; ) in this code? Udoo neo not supported this function. Thanks! NOTE: this question was originally posted by @Andriy in this topic.
The ISR part is an interrupt so if you don't need it you can just skip this line (and the attached brackets). Leave the If statement in the sketch and put some delay() in it and it will run. The only part that puzzles me personally is the PortB part. It seems to be a direct access to the digital pins on a Arduino. You have to change that into a digitalwrite() but on what pin? The sketch can only run on some Arduino's so it is not the best example that Grove could give.
I am a beginner in programming. If you have the opportunity to write the desired function in the code. I will be grateful.
Quick and dirty and did not run it trough the compiler so no guarantees And I was a beginner too when i bought the Neo, there is a lot of info out there! Code: /* AirQuality Demo V1.0. connect to A1 to start testing. it will needs about 20s to start * By: [URL='http://www.seeedstudio.com/']http://www.seeedstudio.com[/URL] */ #include "AirQuality.h" #include "Arduino.h" int current_quality =-1; void setup() { Serial.begin(115200); delay(100); AirQuality airqualitysensor; airqualitysensor.init(14); } void loop() { current_quality=airqualitysensor.slope(); if (current_quality >= 0)// if a valid data returned. { if (current_quality==0) Serial.println("High pollution! Force signal active"); else if (current_quality==1) Serial.println("High pollution!"); else if (current_quality==2) Serial.println("Low pollution!"); else if (current_quality ==3) Serial.println("Fresh air"); } if(airqualitysensor.counter==20) //set 2 seconds as a detected duty { airqualitysensor.last_vol=airqualitysensor.first_vol; airqualitysensor.first_vol=analogRead(A0); airqualitysensor.counter=0; airqualitysensor.timer_index=1; digitalwrite(13, HIGH); } else { delay(100); airqualitysensor.counter++; digitalwrite(13, LOW); } }