라즈베리파이 BLUETOOTH 소스코드 RASPBERRY-PI #include #include #define BLUE_PORT "/dev/rfcomm0" #define BAUD_RATE 115200 int main(void) { int dev; if((dev = serialOpen(BLUE_PORT, BAUD_RATE)) < 0) { return -1; } printf("Port Open.\n"); serialFlush(dev); while(1) { char ch = serialGetchar(dev); if(ch=='x') { break; } else { fputc(ch, stderr); serialPutchar(dev, ch); } } printf("Port Closed.\n"); serialClose..
라즈베리파이 IR(적외선) 소스코드 RASPBERRY-PI #include #include const int pinIr = 19; int main(void) { wiringPiSetupGpio(); pinMode(pinIr, INPUT); while(1) { if(!digitalRead(pinIr)) { printf("Read\n"); delay(100); } } return 0; }
라즈베리파이 카메라 (CAMERA) 소스코드 1 RASPBERRY-PI 카메라를 움직여 가면서 영상을 찍고 파일 저장을 한다. #include #include #include const int pinServoUD = 17; const int pinServoLR = 18; int main(void) { wiringPiSetupGpio(); softPwmCreate(pinServoUD, 0, 200); softPwmCreate(pinServoLR, 0, 200); while(1) { softPwmWrite(pinServoUD, 1); delay(500); softPwmWrite(pinServoUD, 10); delay(500); softPwmWrite(pinServoUD, 20); delay(500); so..
라즈베리파이 SOUND 1 소스코드 RASPBERRY-PI #include #include #include #define CS_ADC7 #define SPI_CHANNEL0 #define SPI_SPEED1000000 int adcRead(char adcChannel) { char buff[3]; int adcValue = 0; buff[0] = 0x06 |((adcChannel & 0x07) >>2); buff[1] = ((adcChannel &0x07)
라즈베리파이 소리(SOUND) 소스코드 RASPBERRY-PI 1 #include #include #include #define CS_ADC7 #define SPI_CHANNEL0 #define SPI_SPEED1000000 int adcRead(char adcChannel) { char buff[3]; int adcValue = 0; buff[0] = 0x06 |((adcChannel & 0x07) >>2); buff[1] = ((adcChannel &0x07)
라즈베리파이 VR 코드 1 ADS SPEED SPI CS #include #include #include #define CS_ADC7 #define SPI_CHANNEL0 #define SPI_SPEED1000000 int adcRead(char adcChannel) { char buff[3]; int adcValue = 0; buff[0] = 0x06 | ((adcChannel & 0x07)>>2); buff[1] = ((adcChannel &0x07)
라즈베리파이 EEPROM 사용하기 2 RASPBERRY-PI #include #include #include #include #define CS_EEPROM8 #define SPI_CHANNEL0 #define SPI_SPEED1000000 #define WREN 0x06 #define WRDI0x04 #define RDSR0x05 #define WRSR0x01 #define READ0x03 #define WRITE0x02 int main(void) { char buff[9]; wiringPiSetupGpio(); if(wiringPiSPISetup(SPI_CHANNEL, SPI_SPEED)
라즈베리파이 TEMP HUMI 온도 습도 코드 1 #include #include #include #define SHT20_I2C_ADDR0x40 #define SHT20_I2C_CMD_MEASURE_TEMP0xF3 #define SHT20_I2C_CMD_MEASURE_HUMI0xF5 #define SHT20_SOFT_RESET0xFE int fd; int main(void) { float temp = 0.0; float humi = 0.0; int aData[2]; int value; int i; if((fd=wiringPiI2CSetup(SHT20_I2C_ADDR))
라즈베리파이 CDS 조도센서 코드 1 #include #include #include #define CS_ADC7 #define SPI_CHANNEL0 #define SPI_SPEED1000000 int adcRead(char adcChannel) { char buff[3]; int adcValue = 0; buff[0] = 0x06 |((adcChannel & 0x07)>>2); buff[1] = ((adcChannel &0x07)
라즈베리파이 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))