[아두이노] 키패드 입력받기
IoT/Arduino2020. 5. 26. 19:26[아두이노] 키패드 입력받기

#include const byte rows = 4; //four rows const byte cols = 4; //three columns char keys[rows][cols] = { {'1','2','3','A'}, {'4','5','6','B'}, {'7','8','9','C'}, {'*','0','#','D'} }; byte rowPins[rows] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad byte colPins[cols] = {5, 4, 3, 2}; //connect to the column pinouts of the keypad Keypad customKeypad = Keypad( makeKeymap(keys), rowPins,..

[아두이노] 아날로그 핀으로 모터움직이기(MAP함수)
IoT/Arduino2020. 5. 26. 19:16[아두이노] 아날로그 핀으로 모터움직이기(MAP함수)

#include Servo myservo; // 서보모터 생성 int potpin = A0; //아날로그 핀 연결 int val; //핀 값 변수 void setup() { myservo.attach(9); Serial.begin(9600); } void loop() { val = analogRead(potpin); val = map(val, 0, 1023, 0, 180); myservo.write(val); Serial.println(val); delay(15); }

[아두이노] IR리모컨을 이용한 LED RGB변경
IoT/Arduino2020. 5. 26. 16:42[아두이노] IR리모컨을 이용한 LED RGB변경

#include // 핀 선언 int red = 9; int green = 13; int blue = 10; int RECV_PIN = 11; IRrecv irrecv(RECV_PIN); decode_results results; void setup() { pinMode(red,OUTPUT); pinMode(green,OUTPUT); pinMode(blue,OUTPUT); Serial.begin(9600); irrecv.enableIRIn(); // start the receiver } void loop() { if(irrecv.decode(&results)){ Serial.println(results.value, HEX); irrecv.resume(); // receive the next value /..

[아두이노] LCD 텍스트 출력
IoT/Arduino2020. 5. 21. 21:59[아두이노] LCD 텍스트 출력

/* LiquidCrystal Library - Hello World Demonstrates the use a 16x2 LCD display. The LiquidCrystal library works with all LCD displays that are compatible with the Hitachi HD44780 driver. There are many of them out there, and you can usually tell them by the 16-pin interface. This sketch prints "Hello World!" to the LCD and shows the time. The circuit: * LCD RS pin to digital pin 12 * LCD Enable ..

[아두이노] 7세그먼트
IoT/Arduino2020. 5. 21. 21:09[아두이노] 7세그먼트

- 아노드 + 연결 - 케소드 - 연결 일반방식으로 켜기 void setup() { pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); } void loop() { digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); delay(10); } 배열선언해서 켜기 byte num[3][7] = { {1,1,1,1,1,1,0}, {0,1,1,0,0,0,0}, {1,1,0,1,1,0,1} }; //3개의 숫자를 표현하기 위해 //각각 숫자마다 7개의 led관리하기 위해 void displayNum(int n){ for(int i=0; i

image