Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unsigned int data_pres = 0;
- unsigned int avg = 0;
- #include <movingAvg.h>
- movingAvg avgPres(20);
- #include <SoftwareSerial.h>
- SoftwareSerial nexSerial(3, 2); // RX, TX
- void setup() {
- Serial.begin(9600);
- nexSerial.begin(9600);
- pinMode(A0, INPUT);
- avgPres.begin();
- delay(1000);
- }
- void loop() {
- //data_pres = map(analogRead(A0),0,1024,0,255); //Read the pot value ann map it to 0.255 (max value of waveform=255)
- data_pres = analogRead(A0)*4;
- avg = avgPres.reading(data_pres);
- Serial.println(avg);
- String Tosend = "add ";
- Tosend += 1;
- Tosend += ",";
- Tosend += 0;
- Tosend += ",";
- Tosend += data_pres;
- nexSerial.print(Tosend);
- nexSerial.write(0xff);
- nexSerial.write(0xff);
- nexSerial.write(0xff);
- delay(5);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement