목록전체 글 (351)
printf("ho_tari\n");
const int fnd_data[7] = { 2, 3, 4, 5, 6, 7, 8}; // a, b, c, d, e, f, g const int num_0[7] = { 1, 1, 1, 1, 1, 1, 0}; const int num_1[7] = { 0, 1, 1, 0, 0, 0, 0}; const int num_2[7] = { 1, 1, 0, 1, 1, 0, 1}; const int num_3[7] = { 1, 1, 1, 1, 0, 0, 1}; const int num_4[7] = { 0, 1, 1, 0, 0, 1, 1}; const int num_5[7] = { 1, 0, 1, 1, 0, 1, 1}; const int num_6[7] = { 1, 0, 1, 1, 1, 1, 1}; const int nu..
#include #include const int trig_pin = 11; const int echo_pin = 12; int start_flag = 1; 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 timer..
#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,512); for(int note=0; note
#include const int LED = 5; int ledFlag = 0; void timerIsr(void) { if(ledFlag == 0){ digitalWrite(LED, HIGH); ledFlag = 1; } else if(ledFlag == 1){ 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); // Timer1 인..
#include #include // ECHO pin #define ECHO_INPUT 2 // TRIG pin #define TRIG_OUTPUT 3 // update interval, make sure to keep it above 20ms #define ULTRASONIC_TIMER_US 500000 // the time the pulse was sent volatile unsigned long ultrasonic_echo_start = 0; // the distance once it's been measured volatile unsigned long ultrasonic_distance = 0; void ultrasonicPulse(){ digitalWrite(TRIG_OUTPUT, HIGH); ..
const int BUZZER = 10; const int note[9] = {-1, 262, 294, 330, 349, 393, 440, 494, 523}; void setup() { // put your setup code here, to run once: Serial.begin(115200); } void loop() { // put your main code here, to run repeatedly: if(Serial.available()) { char userInput = Serial.read(); if('1'
const int Xin = A0; const int Yin = A1; const int KEYin = 3; void setup() { // put your setup code here, to run once: Serial.begin(115200); pinMode(KEYin, INPUT_PULLUP); } void loop() { // put your main code here, to run repeatedly: int xVal = analogRead(Xin); int yVal = analogRead(Yin); int buttonVal = digitalRead(KEYin); Serial.print("X= "); Serial.println(xVal, DEC); Serial.print("Y= "); Seri..