1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
int analogPin = 0;    // 워터센서 analog port 0 연결 선언
int val = 0;          // 전류변화값 변수선언
 
void setup ()
{
  Serial.begin (9600);           // 시리얼모니터 설정
}
 
void loop()
{
  val = analogRead(analogPin);   // analogPin 의 변화값(전류값)을 읽음
 
  Serial.println(val);      // 시리얼모니터에 전류값 표시
  delay (500);
}
 
cs


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int sensorPin = A0;    // select the input pin for the potentiometer
int sensorValue = 0;  // variable to store the value coming from the sensor
 
void setup() {
  // declare the ledPin as an OUTPUT:
   Serial.begin(9600);  
}
 
void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);    
  delay(1000);          
  Serial.print("sensor = " );                       
  Serial.println(sensorValue);                   
}
cs


+ Recent posts