Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
- Committer:
- daviwang
- Date:
- 2017-03-31
- Revision:
- 1:2e895e5272ab
- Parent:
- 0:1c15cf9cc4f9
- Child:
- 2:f501e506d62b
File content as of revision 1:2e895e5272ab:
#include "mbed.h"
DigitalOut myled(LED1);
Serial pc(USBTX, USBRX);
I2C camera1(p9, p10);
int IRsensorAddress = 0xB0;
int slaveAddress;
char data_buf[16];
int i;
//sensitivity
//Level 5: p0 = 0x96, p1 = 0xFE, p2 = 0xFE, p3 = 0x05
int sen0 = 0x96;
int sen1 = 0xFE;
int sen2 = 0xFE;
int sen3 = 0x00;
int Ix[4];
int Iy[4];
int s;
void write2bytes(char data1, char data2){
char out[2];
out[0] = data1;
out[1] = data2;
camera1.write(slaveAddress, out, 2);
wait(0.01);
}
void initCamera(void){
// Initialize WiiMote Camera
write2bytes(0x30, 0x01);
write2bytes(0x00, 0x02);
write2bytes(0x00, 0x00);
write2bytes(0x71, 0x01);
write2bytes(0x00, sen0);
write2bytes(0x07, 0x00);
write2bytes(sen1, 0x1A);
write2bytes(sen2, sen3);
write2bytes(0x33, 0x03);
write2bytes(0x30, 0x08);
wait(0.1);
}
int main() {
myled = 0;
slaveAddress = IRsensorAddress >> 1;
initCamera();
while(1) {
myled = myled - 1;
char out[1];
out[0] = 0x36;
camera1.write(slaveAddress, out, 1);
wait(0.2);
}
}

