Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h>
- LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
- const int backlight = 10;
- #define sample 300
- int inPin = 5;
- float val;
- int pin11 = 13;
- int array1[sample];
- unsigned long averaging;
- void setup() {
- pinMode(backlight, OUTPUT);
- digitalWrite(backlight, HIGH);
- lcd.begin(16,2);
- lcd.print("EMF Tester");
- lcd.setCursor(0,1); //Va alla riga 1
- }
- void loop() {
- for(int i = 0; i < sample; i++){
- array1[i] = analogRead(inPin);
- averaging += array1[i];
- }
- val = averaging / sample;
- val = constrain(val, 0, 100);
- val = map(val, 0, 100, 0, 255);
- analogWrite(pin11, val);
- averaging = 0;
- lcd.setCursor(0,1);
- lcd.print(val);
- lcd.print(" ");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement