Skip to content

Commit 9b48fa0

Browse files
committed
code and images for water level sensor
1 parent d2ae6a6 commit 9b48fa0

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

Water Level Sensor with Arduino/README.md

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
// Sensor pins pin D6 LED output, pin A0 analog Input
3+
#define ledPin 6
4+
#define sensorPin A0
5+
6+
void setup() {
7+
Serial.begin(9600);
8+
pinMode(ledPin, OUTPUT);
9+
digitalWrite(ledPin, LOW);
10+
11+
}
12+
13+
void loop()
14+
{
15+
unsigned int sensorValue = analogRead(sensorPin);
16+
17+
if (sensorValue < 540)
18+
return;
19+
20+
uint8_t outputValue = map(sensorValue, 540, 800, 0, 255);
21+
Serial.print(sensorValue);
22+
Serial.print(" ");
23+
Serial.println(outputValue);
24+
analogWrite(ledPin, outputValue); // generate PWM signal
25+
}
Loading

0 commit comments

Comments
 (0)