목록Arduino(C,C++) (20)
Creative Code
const int fnd_digit[6] = {A0,A1,A2,A3,A4,A5}; const int fnd_data[7] = {2,3,4,5,6,7,8}; int arr[6] = {0,0,0,5,2,5}; const unsigned int num[10][7] = {{1,1,1,1,1,1,0}, {0,1,1,0,0,0,0}, {1,1,0,1,1,0,1}, {1,1,1,1,0,0,1}, {0,1,1,0,0,1,1}, {1,0,1,1,0,1,1}, {1,0,1,1,1,1,1}, {1,1,1,0,0,0,0}, {1,1,1,1,1,1,1}, {1,1,1,1,0,1,1}}; int cnt = 0; void displayinit() { for (int i = 0; i
const int fnd_data[7] = {2,3,4,5,6,7,8}; const unsigned int num[10][7] = {{1,1,1,1,1,1,0}, {0,1,1,0,0,0,0}, {1,1,0,1,1,0,1}, {1,1,1,1,0,0,1}, {0,1,1,0,0,1,1}, {1,0,1,1,0,1,1}, {1,0,1,1,1,1,1}, {1,1,1,0,0,0,0}, {1,1,1,1,1,1,1}, {1,1,1,1,0,1,1}}; void displayinit(int *pin) { for (int i = 0; i
#include #include const int trig_pin = 9; const int echo_pin = 10; unsigned long echo_duration =0; void echoIsr(void) { static unsigned long echo_begin = 0; static unsigned long echo_end = 0; unsigned int echo_pin_state = digitalRead(echo_pin); if (echo_pin_state == HIGH) { echo_begin = micros(); } else { echo_end = micros(); echo_duration = echo_end - echo_begin; } } void timerIsr(void) { if (e..
#include const int BUZZER = 10; const int melody[] = {262,294,330,349,393,440,494,523,}; void setup() { // put your setup code here, to run once: Timer1.initialize(); Timer1.pwm(BUZZER,0); Timer1.setPwmDuty(BUZZER,100); for (int note = 0; note
#include const int LED = 10; // timer1 을 쓰기위해서는 9,10번핀에 연결 int ledflag = 0; void timerIsr(void) { if (ledflag == 0) { digitalWrite(LED,HIGH); ledflag = 1; } else { digitalWrite(LED,LOW); ledflag = 0; } } void setup() { // put your setup code here, to run once: pinMode(LED,OUTPUT); Timer1.initialize(1000000); //Timer1.pwm(LED,0); //timer1을 이용하여 pwm기능을 사용하는 경우 설정 Timer1.attachInterrupt(timerIsr); ..
const int trig_pin =11; const int echo_pin =12; void setup() { // put your setup code here, to run once: pinMode(trig_pin,OUTPUT); pinMode(echo_pin,INPUT); Serial.begin(115200); } void loop() { // put your main code here, to run repeatedly: digitalWrite(trig_pin,LOW); delayMicroseconds(2); digitalWrite(trig_pin,HIGH); delayMicroseconds(10); digitalWrite(trig_pin,LOW); long duration = pulseIn(ech..