-
Notifications
You must be signed in to change notification settings - Fork 0
/
pressure_transmitter.ino
39 lines (31 loc) · 1.13 KB
/
pressure_transmitter.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//The circuit:
//Pressure sensor code
// These constants won't change. They're used to give names
// to the pins used:
const int analogInPin = A0; // Analog input pin that the pressure sensor is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to
int sensorValue = 0; // value read from the port
int outputValue = 0; // value output to the PWM (analog out)
void setup() {
// put your setup code here, to run once:
// Initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 100, 1023, 0, 367);
// change the analog out value:
// analogWrite(analogOutPin, outputValue);
//print the results to the serial monitor:
//Serial.print("sensor = ");
//Serial.print(sensorValue);
Serial.print("PSI ");
Serial.println(outputValue);
// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
//after the last reading:
delay(2);
}