본문 바로가기

Lobo's study room/아두이노

오픈소스와 IOT. 아두이노와 택트스위치 연동하기.

#오픈소스?

누구나 자신의 아이디어를 ICT 분야에 접목시킬 수 있는 강력한 수단으로

처음에 상업용 목적이 아닌 유닉스를 상업용으로 전환하려고해서 

오픈소스로 돈 걱정없이 누구나 자유롭게 사용할수 있는 리눅스가 등장하게되었다.

ICT+인터넷=IOT

최근에는 개인 메이커, 크라우드 펀딩 등장

 

#알아두면 유용한 오픈소스 개발 툴

1.Fritzing

https://fritzing.org/

 

Fritzing

Fritzing is an open-source hardware initiative that makes electronics accessible as a creative material for anyone. We offer a software tool, a community website and services in the spirit of Processing and Arduino, fostering a creative ecosystem that allo

fritzing.org

오픈소스 회로설계 툴로서 실제 소자 또는 모듈과 흡사한 모양의 아이콘을 활용.

직관적인 인터페이스로 회로를 직접 만들어볼수 있다.

2.Processing

https://processing.org/

 

Welcome to Processing!

Processing is a flexible software sketchbook and a language for learning how to code within the context of the visual arts. Since 2001, Processing has promoted software literacy within the visual arts…

processing.org

컴퓨터를 활용한 시각디자인 툴로 개발되었으나 현재는 아두이노 등으로 구현한 전자회로의 센서값의 변화등을 시각화하는 툴로 많이 이용되는 툴!

3.App Inventor

http://appinventor.mit.edu/

 

MIT App Inventor | Explore MIT App Inventor

Use MIT App Inventor To Create Alexa Skills for Astronauts! A fantastic new collaboration between Amazon, National Science Teaching Association (NSTA), Mobile CSP and MIT App Inventor. Alexa for Astronauts lets students become virtual crew members as Alexa

appinventor.mit.edu

쉽게 안드로이드 어플 구축가능

 

#아두이노 명칭의 유래

마지막 이탈리아 출신의 통치자였던 Arduin of Ivrea.

 

#아두이노 통합개발환경 설치

https://www.arduino.cc/

 

Arduino - Home

 

www.arduino.cc

software-download-just download

 

#아두이노 개발환경 설정

-툴-보드-Arduino/해당하는 보드 선택!

우노를 주로 사용하기도 하구 우노를 사용할거라 필자는 우노 선택!

-툴-포트-COMx(해당하는 보드)

 

#아두이노 실습 - Blink 예제

파일-예제-01 Basic - Blink 예제 선택 및 업로드

 

#오늘의 실습 회로도

 

 

 

 

void setup(){
pinMode(LED_BUILTIN, OUTPUT);

void loop(){
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrtie(LED_BUILTIN, LOW);
delay(1000);
}

 

#아두이노 실습 - pull-up

const int pinSW = 2;
const int pinLED = 13;

void setup(){
	pinMode(pinSW, INPUT);
    pinMode(pinLED, OUTPUT);
}
    
void loop(){
	digital Write(pinLED, !digitalRead(pinSW));
}

 

#아두이노 실습 - pull-up-inside

const int pinSW = 2;
const int pinLED = 13;

void setup(){
	pinMode(pinSW, INPUT_PULLUP);
	pinMode(pinLED, OUTPUT);
}

void loop(){
	digitalWrite(pinLED,!digitalRead(pinSW));
}

#아두이노 실습 - toggle_1

#define ON 0
#define OFF 1

const int pinSW = 2;
const int pinLED = 13;

unsigned int count = 0;
unsigned int key_check_deay = 90;

void setup(){
	pinMode(pinSW, INPUT_PULLUP);
    pinMode(pinLED, OUTPUT);
    Serial.begin(9600); //baud:한번에 변조 비트수 - 9600
}

void loop(){
	if(digitalRead(pinSW) == ON){
    	delay(key_check_delay);
    
    if(digitalRead(pinSW) == ON){
    	count++;
        if(count == 100) count = 0;
   	digitalWrite(pinLED, count % 2);
    Serial.println(count);
    }
    }
    else;
 }

토글스위치 한번누를때마다 여러번 누르는것을 방지하고 한번에 하나씩만 카운팅해서

누를때마다 켜고 끄고 할 수 있게 기능 구현.

 

#기타 개발 이론 정리

 

TTL

Time to live

컴퓨터나 네트워크에서 데이터의 유효 기간을 나타내기 위한 방법으로 계수기나 타임스탬프의 형태로 데이터에 포함되며, 정해진 유효기간이 지나면 데이터는 폐기된다.

 

건전지가 1개 / 2개(병렬) / 2개(직렬) 로 연결되었을때 

2개 병렬일때 1개일때와 전기 세기는 같지만 더 오래 건전지를 사용할 수 있고

2개 직렬일때 전기세기는 더 세지만 건전지 사용량은 1개 사용량일때와 같다.

 

전위와 저항은 전류랑 비례한다.

전류는 전압/저항과 같다.

부하*전압=전압강하 하지만 직렬. 폐회로일때만 이론이 성립한다.

 

전류법칙 : 저항이있으면 전압은 적게 흐른다.

 

그라운드 : 전위가 0인지점. 기준점. 신호의 레벨을 한 곳에 모은다.

어스 : 접지. 땅에다 묻는것.

 

풀업. 풀다운 : 스위치 입력다운 받을때.

풀업 : 전원전압을 잡아당긴다

풀다운 : 그라운드를 잡아당긴다.

스위치 : 흑갈적등황녹청자회백

            0 1 2 3  4 5 6 7  8 9

갈흑흑/적 - 100 * 10

갈흑등 - 10 * 10 ^ 3

 

GPIU : General Purpose Input Output

~ : analong output

 

비트연산 :

128   64   32   16   8     4    2     1

2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0

1      0     1    1    0      0     1    1

128 b3 0xb3

 

LSB : Least Significant Bit

MSB : Most Significant Bit