공부,일/아두이노7 arduino conect to C# 아두이노랑 Serial 입력하는 방법 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO.Ports; namespace Serial { class Program { static void Main(string[] args) { SerialPort ObjSerial = new SerialPort(); ObjSerial.PortName = "COM3"; ObjSerial.BaudRate = 9600; ObjSerial.DataBits = 8; ObjSerial.Parity = Parity.None; ObjSerial.StopBi.. 2021. 7. 19. 아두이노 통신 1.병렬 통신 병렬 통신 bit 당 1선 필요 + clk + ground ex) cpu 에서 bus 사용할때 사용하는 통신 방식 1 clk 에 8 bit 전송 가능 보통 ground 선은 무조건 필요함으로 보통 그라운드 선을 제외하고 9선 필요하다고 표현한다. 2. 직렬 통신 동기식과 비동기식 - 동기식 : Clock 라인을 이용해 데이터 전송 타이밍을 맞춤 (synchronous) I2C, SPI 통신이 대표적 - 비동기식 : Clock 라인 없이 양측이 미리 합의된 클럭 사용 (asynchronous) Serial(UART) 통신이 대표 비동기식은 데이터 시작과 끝을 알리는 신호를 보내기 때문에 더욱 느리다. 2021. 7. 19. 조이스틱 void setup() { pinMode(6, INPUT_PULLUP); // 버튼 핀을 읽기 모드로 Serial.begin(9600); } void loop() { int vertical, horizontal, select; vertical = analogRead(A0); // x축 = 0-1023 horizontal = analogRead(A1); // y축 = 0-1023 select = digitalRead(6); // 버튼, 눌렀을 때 = LOW, 뗐을 때 = HIGH Serial.print("X = "); Serial.print(vertical); Serial.print(", Y = "); Serial.print(horizontal); Serial.print(", Button = "); if(.. 2021. 7. 19. 초음파 센서 void setup() { Serial.begin(9600); pinMode(2,OUTPUT); // 센서 Trig 핀 pinMode(3,INPUT); // 센서 Echo 핀 } void loop() { int duration, cm; digitalWrite(2,HIGH); // 센서에 Trig 신호 입력 delayMicroseconds(10); // 10us 정도 유지 digitalWrite(2,LOW); // Trig 신호 off duration = pulseIn(3, HIGH); // Echo pin: HIGH->Low 간격을 측정 cm = microsecondsToCentimeters(duration); // 거리(cm)로 변환 Serial.print(cm); Serial.println("cm").. 2021. 7. 19. 아두이노 회로 실습 (1) cds (조도 센서 실습) void setup() { Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly int sensorValue = analogRead(A1); Serial.println(sensorValue); delay(100); } Interrupt 우노는 2 , 3 번 핀에만 interrup 생성 가능 void setup() { // put your setup code here, to run once: pinMode(13, OUTPUT); pinMode(2, OUTPUT); attachInterrupt(1, blink, CHANGE); // D3 핀에 인터럽트 설정 } void loop() { //.. 2021. 7. 16. 아두이노 회로 실습 (by fritzing ) https://wowcat.tistory.com/3070 프리징 회로설계 fritzing 0.9.3b 64bit download wowcat.tistory.com 안에 있는거 13개 다운 하고 압출 풀면 사용 가능 AnalogWrite - PWM 예제AnalogWrite - PWM 예제AnalogWrite - PWM 예제 void setup() { // put your setup code here, to run once: pinMode(7,OUTPUT); } void loop() { // put your main code here, to run repeatedly: digitalWrite(7,HIGH); delay(500); // ms 단위 digitalWrite(7,LOW); delay(500); //.. 2021. 7. 15. 아두이노 실습환경 구축 https://www.arduino.cc/ Arduino - Home www.arduino.cc 접속 zip 파일 다운로드 압축 풀고 dirvers 까지의 경로 복사 장치관리자에서 usb 직렬 장치 선택 내 드라이버 위치 붙이기 실행 모습 보드가 우리가 사용중인 보드이름과 맞춰준다. 나는 uno 를 사용하기 때문에 uno 로 설정 포트를 장치 포트와 동일하게 연결 정보 뜨면 환경 구축 끝 2021. 7. 14. 이전 1 다음