ตัวอย่างงานที่ใช้โปรแกรม Arduino
การเขียนโปรแกรมเบื้องต้นกับ Arduino C++ (การรับค่าสัญญาณ Analog)
ตัวอย่าง Code
// select the input pin for the potentiometerint sensorPin = A3;// select the pin for the LEDint ledPin = 13;// variable from the sensorint sensorValue = 0;void setup() { // declare the ledPin as an OUTPUT: pinMode(ledPin, OUTPUT); Serial.begin(9600);}void loop() { // read the value from the sensor: sensorValue = analogRead(sensorPin); //print report: Serial.println(sensorValue); //call Blinky LED Blinky(sensorValue);}void Blinky(int time) { digitalWrite(ledPin, HIGH); delay(time); digitalWrite(ledPin, LOW); delay(time);}
อ้างอิง : http://www.myarduino.net/article/24/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%80%E0%B8%82%E0%B8%B5%E0%B8%A2%E0%B8%99%E0%B9%82%E0%B8%9B%E0%B8%A3%E0%B9%81%E0%B8%81%E0%B8%A3%E0%B8%A1%E0%B9%80%E0%B8%9A%E0%B8%B7%E0%B9%89%E0%B8%AD%E0%B8%87%E0%B8%95%E0%B9%89%E0%B8%99%E0%B8%81%E0%B8%B1%E0%B8%9A-arduino-c-%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%A3%E0%B8%B1%E0%B8%9A%E0%B8%84%E0%B9%88%E0%B8%B2%E0%B8%AA%E0%B8%B1%E0%B8%8D%E0%B8%8D%E0%B8%B2%E0%B8%93-analog
ไม่มีความคิดเห็น:
แสดงความคิดเห็น