라즈베리파이 카메라 (CAMERA) 소스코드
- 코딩/Raspberry Pi (c)
- 2019. 11. 22.
라즈베리파이 카메라 (CAMERA) 소스코드 1 RASPBERRY-PI
카메라를 움직여 가면서 영상을 찍고 파일 저장을 한다.
#include <stdio.h>
#include <wiringPi.h>
#include <softPwm.h>
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);
softPwmWrite(pinServoUD, 10);
delay(500);
system("raspistill -t 10000 -o video.mp4");
softPwmWrite(pinServoLR, 5);
delay(500);
softPwmWrite(pinServoLR, 15);
delay(500);
softPwmWrite(pinServoLR, 25);
delay(500);
softPwmWrite(pinServoLR, 15);
delay(500);
system("raspistill -t 10000 -o video.mp4");
}
return 0;
}
라즈베리파이 카메라 (CAMERA) 소스코드 1 RASPBERRY-PI
#include <stdio.h>
#include <wiringPi.h>
#include <wiringPiI2C.h>
#define SERVO_I2C_ADDR 0x20
#define OUT_PORT0 0x02
#define CONFIG_PORT0 0x06
const int period = 20000;
const int pinservoUD = 0x01;
const int pinservoLR = 0x02;
int fd;
int main(void)
{
if((fd = wiringPiI2CSetup(SERVO_I2C_ADDR)) < 0)
{
return -1;
}
wiringPiI2CWriteReg16(fd, CONFIG_PORT0, 0x00);
int i;
wiringPiSetupGpio();
while(1)
{
for(i=0; i<50; i++)
{
wiringPiI2CWriteReg16(fd,OUT_PORT0,pinservoUD);
delayMicroseconds(50);
wiringPiI2CWriteReg16(fd, OUT_PORT0, 0x00);
delayMicroseconds(period-50);
}
for(i=0; i<50; i++)
{
wiringPiI2CWriteReg16(fd, OUT_PORT0,pinservoUD);
delayMicroseconds(600);
wiringPiI2CWriteReg16(fd, OUT_PORT0, 0x00);
delayMicroseconds(period-600);
}
for(i=0; i<50; i++)
{
wiringPiI2CWriteReg16(fd, OUT_PORT0, pinservoUD);
delayMicroseconds(1500);
wiringPiI2CWriteReg16(fd, OUT_PORT0, 0x00);
delayMicroseconds(period-1500);
}
for(i=0; i<50; i++)
{
wiringPiI2CWriteReg16(fd, OUT_PORT0, pinservoUD);
delayMicroseconds(50);
wiringPiI2CWriteReg16(fd, OUT_PORT0, 0x00);
delayMicroseconds(period-50);
}
for(i=0; i<50; i++)
{
wiringPiI2CWriteReg16(fd, OUT_PORT0, pinservoUD);
delayMicroseconds(1000);
wiringPiI2CWriteReg16(fd, OUT_PORT0, 0x00);
delayMicroseconds(period-1000);
}
for(i=0; i<50; i++)
{
wiringPiI2CWriteReg16(fd, OUT_PORT0, pinservoUD);
delayMicroseconds(2000);
wiringPiI2CWriteReg16(fd, OUT_PORT0, 0x00);
delayMicroseconds(period-2000);
}
system("raspistill -t 5000 -o image2.jpg");
}
return 0;
}
'코딩 > Raspberry Pi (c)' 카테고리의 다른 글
라즈베리파이 BLUETOOTH 소스코드 (0) | 2019.11.23 |
---|---|
라즈베리파이 IR(적외선) 소스코드 (0) | 2019.11.23 |
라즈베리파이 SOUND 소스코드 (0) | 2019.11.22 |
라즈베리파이 소리(SOUND) 소스코드 (0) | 2019.11.22 |
라즈베리파이 VR 코드 (0) | 2019.11.21 |