The CmuCam5 can't work...

Added by winnie chen 11 days ago

I use the Aduino Mega2560 Bord to connect to the Pixy.
And I use external power supply(11.1V 3S battery)to give Mega2560.
But now the Pixy sometimes doesn't worked,and the LED is always blinking.
I don't know how to fix it.
Hope someone can help me...
Thanks a lot!


Replies (3)

RE: The CmuCam5 can't work... - Added by Edward Getz 6 days ago

Hello Winnie,
Sorry for the problems. When you say it isn't working, are you testing with a simple Adruino program like the hello_world program?

http://cmucam.org/projects/cmucam5/wiki/Hooking_up_Pixy_to_a_Microcontroller_(like_an_Arduino)

When you Say the LED is always blinking, can you describe the color? Does PixyMon work with your Pixy?

Edward

RE: The CmuCam5 can't work... - Added by winnie chen 5 days ago

Thank you Edward,
NO.
But,I use the code is edited from hello_word program.
This is a program of project identify of the car:
--------------------------------------------------------------------------
/************************************************
Use the I2C port pin A4 and A5,this is for Uno board.
A4 is connect to SDA,A5 is connect to SCL
If you use the Mega2560 that I2C port pin at the 20,21.
The <Wire.h> user guid on this web address https://www.arduino.cc/en/Reference/Wire
****************************************/
#include "MeOrion.h"
#include <SoftwareSerial.h>
#include <Wire.h>
#include <SPI.h>
#include <Pixy.h>

MeEncoderNew motor1(0x08,SLOT1);
MeEncoderNew motor2(0x08,SLOT2);
MeEncoderNew motor3(0x09,SLOT1);
MeEncoderNew motor4(0x09,SLOT2);
int Speed_Max = 150;
int Speed_High = 100;
int Speed_Mid = 80;
int Speed_Min = 50;
int Speed_Break= 0;
int Angle;

Pixy pixy;

uint16_t blocks;
int flag;

void setup() {
motor1.begin();
motor2.begin();
Serial.begin(9600);
/*Serial.print("Starting...\n");*/
pixy.init();

}

void loop() {
//----------------------------AUTO FIDING----------------------------
flag = 'o';
if(flag == 'o'){
int blocks = pixy.getBlocks();
int n = 0;
//Serial.println(pixy.blocks0.signature);
//Serial.println(blocks);
if(blocks != 1){
//Serial.println("Looking for...");
//Serial.println(blocks);
CW;
}
else{
Serial.println("Found it!");
Break();
Found_it();
Serial.print(pixy.blocks0.x);
}
}
//-----------------------------------------------------------------------
//----------------------------BT_Control_Mode----------------------------
if(Serial.available()){
BT_Control_Mode();
}
//-----------------------------------------------------------------------
}

void Forward(){ //num 0
motor1.runSpeed(Speed_Max);
motor2.runSpeed(-Speed_Max);
motor3.runSpeed(Speed_Max);
motor4.runSpeed(-Speed_Max);
}

void Backwards(){ //num 1
motor1.runSpeed(-Speed_Max);
motor2.runSpeed(Speed_Max);
motor3.runSpeed(-Speed_Max);
motor4.runSpeed(Speed_Max);
}

void Left(){ //num 2
motor1.runSpeed(-Speed_Max);
motor2.runSpeed(-Speed_Max);
motor3.runSpeed(Speed_Max);
motor4.runSpeed(Speed_Max);
}

void Right(){ //num 3
motor1.runSpeed(Speed_Max);
motor2.runSpeed(Speed_Max);
motor3.runSpeed(-Speed_Max);
motor4.runSpeed(-Speed_Max);
}

void CW{ //num 4
motor1.runSpeed(Speed_Min);
motor2.runSpeed(Speed_Min);
motor3.runSpeed(Speed_Min);
motor4.runSpeed(Speed_Min);
}

void CCW{ //num 5
motor1.runSpeed(-Speed_Min);
motor2.runSpeed(-Speed_Min);
motor3.runSpeed(-Speed_Min);
motor4.runSpeed(-Speed_Min);
}

void Forward_Right(){ //num 6
motor1.runSpeed(Speed_Max);
motor4.runSpeed(-Speed_Max);
}

void Backwards_Right(){ //num 7
motor2.runSpeed(Speed_Max);
motor3.runSpeed(-Speed_Max);
}

void Forward_Left(){ //num 8
motor2.runSpeed(-Speed_Max);
motor3.runSpeed(Speed_Max);
}

void Backwards_Left(){ //num 9
motor1.runSpeed(-Speed_Max);
motor4.runSpeed(Speed_Max);
}

void Break(){ //b
motor1.runSpeed(Speed_Break);
motor2.runSpeed(Speed_Break);
motor3.runSpeed(Speed_Break);
motor4.runSpeed(Speed_Break);
}

void BT_Control_Mode(){
char c=Serial.read();
if(c == 'a'){
flag = 'a';
}
else if(c == 'o'){
flag = 'o';
}
if(flag == 'a'){
Serial.println("BT_Control_Mode");
switch(c){

case 48:
Forward();
Serial.println("0");
//delay(300);
//Break();
break;
case 49:
Backwards();
Serial.println("1");
//delay(300);
//Break();
break;
case 50:
Left();
Serial.println("2");
//delay(300);
//Break();
break;
case 51:
Right();
Serial.println("3");
//delay(100);
//Break();
break;
case 98:
Serial.println("B");
Break();
Break();
break;
}
}
}

void Found_it(){
if(pixy.blocks0.x < 165){
CCW;
}
else if(pixy.blocks0.x > 155){
CW;
}
else{
Break();
}
}
--------------------------------------------------------------------------
When the Pixy is blinking, the LED color is white.
Now, I hope Pixy, can independently work.
So Pixy mustn't connect to the computer.
But,When the Pixy connect to the computer,Pixymon can work.

Forgive my poor english...

RE: The CmuCam5 can't work... - Added by Edward Getz 4 days ago

Hello Winnie,
It's difficult to tell if the problems you are having are caused by the program running on the Arduino or Pixy.

Teaching Pixy an object and getting good detection accuracy can sometimes be an issue. These links might help.

http://cmucam.org/projects/cmucam5/wiki/Teach_Pixy_an_object_2
http://cmucam.org/projects/cmucam5/wiki/Some_Tips_on_Generating_Color_Signatures_2

If this doesn't seem to help, I would recommend trying the hello_world example to make sure it is working as expected.

http://cmucam.org/projects/cmucam5/wiki/Hooking_up_Pixy_to_a_Microcontroller_(like_an_Arduino)

Let me know what you find.

Edward

(1-3/3)