아두이노(arduino) moter 모터 소스코드 0도부터 180도까지 점점 일정한 속도로 움직인다. #include #include LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27,16,2); Servo servo; const int SERVO_PIN = 9; const int VR_PIN = A0; void setup() { // put your setup code here, to run once: lcd.init(); lcd.begin(16, 2); lcd.clear(); lcd.backlight(); Serial.begin(115200UL); pinMode(VR_PIN, INPUT); pinMode(SERVO_PIN, OUTPUT); servo.attach(SE..
아두이노 처음 시작 HelloWorld 출력 소스 void setup() { // put your setup code here, to run once: Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: Serial.println("HelloWorld"); delay(1000); }
아두이노 BLUETOOTH 블루투스소스코드 #include #include const int RX =2; const int TX =3; Servo servo = Servo(); const int SERVO_PIN = 9; const int LED_PIN =7; int i; SoftwareSerial BT = SoftwareSerial(RX,TX); void setup() { // put your setup code here, to run once: Serial.begin(115200UL); BT.begin(9600UL); BT.println("Welcome"); pinMode(LED_PIN,OUTPUT); pinMode(SERVO_PIN, OUTPUT); servo.attach(SERVO_PIN); } ..
아두이노 LED 소스코드 0부터 9까지 0부터 9 -A 까지 LED로 보여지게된다. //enum LED_PINS {LED1=3, LED2, LED3, LED4, LED5}; const int LED_PINS[] = {3,4,5,6,7,8,9,10}; void setup() { // put your setup code here, to run once: // pinMode(3, OUTPUT); // pinMode(4, OUTPUT); // pinMode(5, OUTPUT); // pinMode(6, OUTPUT); // pinMode(7, OUTPUT); for(int i=0;i
아두이노 VRS 소스코드 const int VR_X_PIN = A0; const int VR_Y_PIN = A1; const int VR_PIN = A2; void setup() { // put your setup code here, to run once: pinMode(VR_X_PIN, INPUT); pinMode(VR_Y_PIN, INPUT); pinMode(VR_PIN, INPUT); Serial.begin(115200UL); Servo servo1 = Servo(); Servo servo2 = Servo(); } void loop() { // put your main code here, to run repeatedly: Serial.println(analogRead(A0)); vr_x_value ..
아두이노 LCD 소스코드 #include //#include LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27,16,2); void setup() { lcd.init(); lcd.begin(16, 2); lcd.clear(); lcd.backlight(); Serial.begin(115200UL); lcd.print("Hello world"); lcd.print("!"); lcd.setCursor(0,1); lcd.print("Android."); } void loop() { lcd.setCursor(0,0); lcd.home(); for(int i = 0; i < 2; ++i) { lcd.setCursor(0,i); lcd.print("*****"); delay(100..
아두이노 CDS 조도센서 소스코드 #include LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27,16,2); const int VR_PIN = A0; // 0 const int PWM_RED_PIN = 9; void setup() { // put your setup code here, to run once: lcd.init(); lcd.begin(16, 2); lcd.clear(); lcd.backlight(); Serial.begin(115200UL); pinMode(VR_PIN, INPUT); pinMode(PWM_RED_PIN, OUTPUT); } void loop() { // put your main code here, to run repeatedly: int..
아두이노 ULTRA SONIC 소스코드 1 void callUltrasonic() { digitalWrite(TRIGGER_PIN, LOW); delayMicroseconds(2); digitalWrite(TRIGGER_PIN, HIGH); delayMicroseconds(10); digitalWrite(TRIGGER_PIN, LOW); long duration = pulseIn(ECHO_PIN, HIGH); /*high가들어올때까지 기다림*/ const unsigned long distance_mm = (duration/ 2.9)/2; /** * 거리가 200mm 인 경우 아랫코드 실행 */ if(distance_mm > 100UL && distance_mm < 1000UL) { Serial.print..
아두이노 Serial 처음 시작 void setup() { // put your setup code here, to run once: Serial.begin(115200UL); } void loop() { // put your main code here, to run repeatedly: if (Serial.available() > 0) { String temp = String(Serial.read()); Serial.println(temp); Serial.write(temp); } }
아두이노 RGB_LED 소스코드 #include LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27,16,2); const int VR_PIN = A0; // 0 const int PWM_RED_PIN = 9; void setup() { // put your setup code here, to run once: lcd.init(); lcd.begin(16, 2); lcd.clear(); lcd.backlight(); Serial.begin(115200UL); pinMode(VR_PIN, INPUT); pinMode(PWM_RED_PIN, OUTPUT); } void loop() { // put your main code here, to run repeatedly: int ..