본문 바로가기

임베디드129

C언어 소켓통신 hello_server.c https://m.blog.naver.com/PostView.nhn?blogId=wndrlf2003&logNo=220001255564&proxyReferer=https:%2F%2Fwww.google.com%2F 네트워크기초 11주차(2) (TCP/IP 1:1 에코서버 C로 작성, 클라이언트 대기 방식) > 네트워크기초 11주차(2) (TCP/IP 1:1 에코서버 C로 작성, 클라이언트 대기 방식) └ 접기 blog.naver.com #include // ANSI C #include // ANSI C #include // ANSI C #include // unix 표준 #include //버클리 소켓 #include //소켓 기본 void error_handling(char* message); int ma.. 2020. 9. 23.
analogWrite() 함수 Description Writes an analog value (PWM wave) to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds. After a call to analogWrite(), the pin will generate a steady rectangular wave of the specified duty cycle until the next call to analogWrite() (or a call to digitalRead() or digitalWrite()) on the same pin. You do not need to call pinMode() to set the pi.. 2020. 9. 18.
RGB LED 랜덤함수 pinMode(2, OUTPUT); 아날로그에 연결 했을때는 핀모드 입력 해주나 안해주나 똑같이 동작한다 int BLUE = 11; int GREEN = 10; int RED = 9; int i; long randNumber; void setup() { //pinMode(BLUE, HIGH);//BLUE //pinMode(GREEN, HIGH);//GREEN //pinMode(RED, HIGH);//RED randomSeed(analogRead(0)); Serial.begin(9600); } void loop() { i = random(1,256); Serial.println(i); analogWrite(BLUE, i); i = random(1,256); Serial.println(i); analogWr.. 2020. 9. 18.
JMOD-BT-01 블루투스 모듈 / dht11 / MIT App Inventor https://appinventor.mit.edu/ MIT App Inventor | Explore MIT App Inventor File Path Updates Starting with Android 10 Android 10 changes how applications can store data. If you use the File component you will want to read this blog entry which discusses how MIT App Inventor is adapting to this change. More appinventor.mit.edu https://firebase.google.com/ Firebase Firebase는 고품질 앱을 빠르게 개발하고 비즈니스를 성장.. 2020. 9. 16.
blynk dht11 /************************************************************* Download latest Blynk library here: https://github.com/blynkkk/blynk-library/releases/latest Blynk is a platform with iOS and Android apps to control Arduino, Raspberry Pi and the likes over the Internet. You can easily build graphic interfaces for all your projects by simply dragging and dropping widgets. Downloads, docs, tutorials:.. 2020. 9. 16.
esp8266 blynk #define BLYNK_PRINT Serial #include #include // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "YourAuthToken"; // Your WiFi credentials. // Set password to "" for open networks. char ssid[] = "YourNetworkName"; char pass[] = "YourPassword"; void setup() { // Debug console Serial.begin(9600); Blynk.begin(auth, ssid, pass); // You can also spec.. 2020. 9. 16.
아두이노 복습..하는...날 . ........... if (serial.available()) #시리얼에 뭐라도 입력되면 if (Serial.available() > 0) 위의 두개 같은 것임 analog값 범위 0~1023 void setup() { pinMode(13, OUTPUT); Serial.begin(9600); } void loop(){ if(Serial.available()){ int input = Serial.read(); if (input == '1'){ digitalWrite(13,HIGH); Serial.println(input); #print 49 } else if (input == '0'){ digitalWrite(13,LOW); Serial.println(input); #print 48 (아스키코드) } } } Serial.pr.. 2020. 9. 15.
arduino pin map 2020. 9. 15.
CLCD16x2 #include //LCD 라이브러리를 추가 //LiquidCrystal lcd(RS, Enable, DB4, DB5, DB6, DB7); LiquidCrystal lcd(3, 4, 5, 7, 10, 13); void setup() { lcd.begin(16, 2); //16열 2행짜리 LCD를 사용하겠다. } void loop() { lcd.setCursor(5, 0); //커서를 (5, 0)으로 보내라 lcd.print("Hello!!"); //(5, 0)부터 Hello!!를 찍어라 } https://m.blog.naver.com/PostView.nhn?blogId=microfun&logNo=220665857658&proxyReferer=https:%2F%2Fwww.google.com%2F [아두이노.. 2020. 9. 10.
아침 저녁 커텐 servo 알람중지 led 온도 습도 dht LCD cds lcd없는코드 #include "DHT.h" #include //Servo 라이브러리를 추가 #define DHTPIN 8 #define DHTTYPE DHT11 #define BUTTON_PIN1 2 //인터럽트 #define BUZZER 6 DHT dht(DHTPIN, DHTTYPE); int ledRed = 11; int cds = A0; Servo servo; //Servo 클래스로 servo객체 생성 int angle = 0; //Servo 각도를 조절할 변수 angle const int buttonPin1 = 2; // 인터럽트 0 volatile long preTime = 0; volatile long curTime = 0; const int deBounce = 200; volatile in.. 2020. 9. 10.
I2C LCD (아이스퀘어 LCD) , CLCD 2X16 16핀 I2C LCD (아이스퀘어 LCD) CLCD 2X16 16핀 2020. 9. 10.
서보모터 #include //Servo 라이브러리를 추가 Servo servo; //Servo 클래스로 servo객체 생성 int value = 0; // 각도를 조절할 변수 value void setup() { servo.attach(7); //맴버함수인 attach : 핀 설정 Serial.begin(9600); //시리얼 모니터 사용 고고 } void loop() { if(Serial.available()) //시리얼 모니터에 데이터가 입력되면 { char in_data; // 입력된 데이터를 담을 변수 in_data in_data = Serial.read(); //시리얼모니터로 입력된 데이터 in_data로 저장 if(in_data == '1') //입력된 데이터가 1이라면 { value += 30; //.. 2020. 9. 9.
0909 신호등 동작 처리 선생님코드 #include #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE 0 #endif const int buttonPin1 = 2; // 인터럽트 0 고정 const int buttonPin2 = 3; // 인터럽트 1 고정 const int buttonPin3 = 4; const int ledRed = 11; const int ledYellow = 9; const int ledGreen = 10; volatile int errFlag = FALSE; volatile int timerCnt; volatile int timerCnt2; volatile long preTime = 0; volatile long curTime = 0; const int.. 2020. 9. 9.
임베디드 애플리케이션 분석 Use Case, actor 2020. 9. 4.
신호등 동작 처리 200903_TrafficLights-1polling_2외부interrupt_3timer #define BUTTON_PIN1 2 #include const int buttonPin1 = 2; // 인터럽트 0 buttonInterrupt1 const int buttonPin2 = 3; // 인터럽트 1 const int buttonPin3 = 4; int LED_R = 11; int LED_Y = 9; int LED_G = 10; volatile long preTime = 0; volatile long curTime = 0; const int deBounce = 200; int buttonState; volatile int checkBtn; volatile int flag=0; volatile int output = HIGH; void setup() { Serial.begin(9600); a.. 2020. 9. 3.
타이머 인터럽트 Timer interrupt #include const int RED = 13; const int BLUE = 12; volatile int output = HIGH; void flash() { digitalWrite(BLUE, output); output = !output; } void setup() { pinMode(RED, OUTPUT); pinMode(BLUE, OUTPUT); MsTimer2::set(500, flash); // 500ms period MsTimer2::start(); } void loop() { digitalWrite(RED, HIGH); delay(2000); digitalWrite(RED, LOW); delay(2000); } 2020. 9. 3.
키입력인터럽트 + LED + buzzer 1button pushed : led red on + buzzer buzz once 2button pushed : led yellow on + buzzer buzz twice 3button pushed : led green on + buzzer buzz 3times /* * 키입력 인터럽트 Update 2019.08.30 by hack4ork * 풀다운 폴링 */ #define BUTTON_PIN1 2 const int buttonPin1 = 2; // 인터럽트 0 const int buttonPin2 = 3; // 인터럽트 1 const int buttonPin3 = 4; volatile char flag=0; volatile long preTime = 0; volatile long curTime = .. 2020. 9. 2.
키입력 인터럽트 /* * 키입력 인터럽트 Update 2019.08.30 by hack4ork */ #define BUTTON_PIN1 2 const int buttonPin1 = 2; // 인터럽트 0 const int buttonPin2 = 3; // 인터럽트 1 const int buttonPin3 = 4; volatile long preTime = 0; volatile long curTime = 0; const int deBounce = 200; void setup() { Serial.begin(9600); attachInterrupt(digitalPinToInterrupt(buttonPin1), buttonInterrupt1, FALLING); attachInterrupt(digitalPinToInterrupt.. 2020. 9. 2.
button Interrupt : ISR (인터럽트 핸들러) // mode : Falling, Rising, Change, Low const int buttonPin1 = 2; //인터럽트 0 const int buttonPin2 = 3; //인터럽트 1 const int buttonPin3 = 4; void setup() { Serial.begin(9600); pinMode(buttonPin1, INPUT); pinMode(buttonPin2, INPUT); pinMode(buttonPin3, INPUT); ////////////////////////////////////////// // 0 :인터럽트 번호 (UNO 0,1 인터럽트 번호) // buttonInterrupt : ISR (인터럽트 핸들러) // mode : Falling, Rising, Change, Low //+++++++++++++++++++++++++++++++.. 2020. 9. 1.
인터럽트 http://blog.naver.com/PostView.nhn?blogId=hy10101010&logNo=221332549568 int button = 2; int LED = 13; void setup() { Serial.begin(115200); pinMode(button,INPUT); pinMode(LED,OUTPUT); digitalWrite(button,INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(button), BUTTON, HIGH); } void loop() { digitalWrite(LED,LOW); delay(100); } void BUTTON() # 인터럽트 핸들러 { digitalWrite(LED,HIGH); delay(100); #사.. 2020. 9. 1.