라즈베리파이 gpio 제어 LIGHT I2C 코드 1 #include #include #include #define LIGHT_I2C_ADDR0x23 #define LIGHT_I2C_POWER_DOWN0x00 #define LIGHT_I2C_POWER_ON0x01 #define LIGHT_I2C_RESET0x07 #define LIGHT_I2C_CON_HR_MODE0x10 int fd; int main(void) { float lightValue = 0.0; int aData[2]; int i; int value; if((fd = wiringPiI2CSetup(LIGHT_I2C_ADDR))
라즈베리파이 LED 코드 1 #include #include #include #define LED_I2C_ADDR 0x20 #define IN_PORT0 0x00 #define IN_PORT1 0x01 #define OUT_PORT00x02 #define OUT_PORT10x03 #define POLARITY_IVE_PORT00x04 #define POLARITY_IVE_PORT10x05 #define CONFIG_PORT0 0x06 #define CONFIG_PORT1 0x07 const int aLedData[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}; int fd; int main(void) { if((fd=wiringPiI2CSetup(LED_..
라즈베리파이 스텝모터 (STEP MOTER)소스코드 1 #include #include #include #define STEP_I2C_ADDR 0x20 #define IN_PORT0 0x00 #define IN_PORT1 0x01 #define OUT_PORT0 0x02 #define OUT_PORT1 0x03 #define POLARITY_IVE_PORT0 0x04 #define POLARITY_IVE_PORT1 0x05 #define CONFIG_PORT0 0X06 #define CONFIG_PORT1 0x07 const int aPhase_1[4] = {0x80, 0x40, 0x20, 0x10}; int fd; int main(void) { if((fd=wiringPiI2CSetup(STEP_I2C..
라즈베리파이 FND 소스코드 #include #include #include #define FND_I2C_ADDR 0x21 #define IN_PORT0 0x00 #define IN_PORT1 0x01 #define OUT_PORT0 0x02 #define OUT_PORT1 0x03 #define POLARITY_IVE_PORT0 0x04 #define POLARITY_IVE_PORT1 0x05 #define CONFIG_PORT0 0x06 #define CONFIG_PORT1 0x07 const int aFndData[10] = {0xFC, 0x60, 0xDA, 0xF2, 0x66, 0xB6, 0x3E, 0xE0, 0xFE, 0xF6}; const int fndSelect = 0xFB; int fd; ..
라즈베리파이 서보(SERVO) 모터 코드 #include #include #include const int pinServo = 17; int main(void) { wiringPiSetupGpio(); softPwmCreate(pinServo, 0, 200); while(1) { softPwmWrite(pinServo, 5); delay(1000); softPwmWrite(pinServo, 15); delay(1000); softPwmWrite(pinServo, 25); delay(1000); softPwmWrite(pinServo, 15); delay(1000); } return 0; }
라즈베리파이 TEXTLCD 코드 1 #include #include #include int main(void) { wiringPiSetupGpio(); int lcd = lcdInit(2, 16, 4, 16, 26, 18, 27, 22, 23, 0, 0, 0, 0); lcdClear(lcd); lcdPosition(lcd, 0, 0); lcdPuts(lcd,"edgeiLAB"); lcdPosition(lcd,0,1); lcdPuts(lcd,"Hello World"); delay(1000); while(1) { } return 0; } 라즈베리파이 TEXTLCD 코드 2 #include #include #include const int pinEcho = 1; const int pinTrigger = 0; ..
라즈베리파이 PIEZO BUZZER (피에조 부저) 소리센서 1 #include #include #include const int pinPiezo = 13; const int aMelody[8] = {131,147,165,175,196,220,247,262}; int main(void) { wiringPiSetupGpio(); softToneCreate(pinPiezo); while(1) { int i; for(i=0;i
라즈베리파이 초음파 거리센서 ULTRASONIC 1 #include #include const int pinEcho = 1; const int pinTrigger = 0; int main(void) { wiringPiSetupGpio(); pinMode(pinEcho, INPUT); pinMode(pinTrigger, OUTPUT); digitalWrite(pinTrigger, LOW); delay(30); while(1) { digitalWrite(pinTrigger, HIGH); delayMicroseconds(20); digitalWrite(pinTrigger, LOW); while(digitalRead(pinEcho)==LOW); long startTime = micros(); while(digi..
라즈베리파이 DC 모터 제어코드 1 #include #include const int pinEnable = 12; const int pinPositive = 4; const int pinNegative = 25; int main(void) { wiringPiSetupGpio(); pinMode(pinEnable, OUTPUT); pinMode(pinPositive, OUTPUT); pinMode(pinNegative, OUTPUT); while(1) { digitalWrite(pinPositive, HIGH); digitalWrite(pinNegative, LOW); digitalWrite(pinEnable, HIGH); delay(2000); digitalWrite(pinEnable, LOW); del..
라즈베리 파이를 이용한 PIR센서 (모션감지) 센서 코드1 #include #include const int pinPir = 24; int main(void) { wiringPiSetupGpio(); pinMode(pinPir, INPUT); while(1) { if(!digitalRead(pinPir)) { printf("Detected\n"); delay(500); } } return 0; } 모션이 감지되면 0.5초 마다 Detected란 문자를 찍어낸다. 라즈베리 파이를 이용한 PIR센서 (모션감지) 센서 코드2 #include #include const int pinPir = 24; const int aPinLed[2] = {21,20}; int main(void) { wiringPiSetupG..