I'm a having a little trouble coding

Added by Drew Kern 14 days ago

I'm having trouble figuring out what the command would be to single out a return on different signatures through my Arduino UNO. Basically what I want is
if signature1 detected then pinMode (13, HIGH);
if signature2 detected then pinMode (12, HIGH);
and so on if needed. //,but I don't know exactly how to do that.


Replies (4)

RE: I'm a having a little trouble coding - Added by Drew Kern 14 days ago

#include <SPI.h>
#include <Pixy.h>
Pixy pixy;
void setup() {
pinMode (13, OUTPUT);
pinMode (12, OUTPUT);
pixy.init();
}
void loop() {
static int i = 0;
int j;
uint16_t blocks;
char buf32;

if (pixy.blocks[i].signature== 1) {
 digitalWrite(13, HIGH);
delay(1000);
}}

Update I've got a "working code" right now I plan to test it tomorrow.

RE: I'm a having a little trouble coding - Added by Edward Getz 14 days ago

Hello Drew,
It looks like you're on the right track ;)

RE: I'm a having a little trouble coding - Added by Drew Kern 9 days ago

#include <SPI.h>
#include <Pixy.h>

// This is the main Pixy object
Pixy pixy;

void setup() {
pinMode (13, OUTPUT);
Serial.begin(9600);
Serial.print("Starting...\n");
pixy.init();
}

void loop() {
static int i = 0;
int j;
uint16_t blocks;
char buf32;
digitalWrite (13, LOW);
// grab blocks!
blocks = pixy.getBlocks();

// If there are detect blocks, print them!
if (blocks) {
if (i%50==0) {
for (j=0; j&lt;blocks; j++) { if (pixy.blocks[j].signature==1)
digitalWrite (13, HIGH);
delay (100);
digitalWrite (13, LOW);
delay (100);
}
}
}
}

This kind of works. when it sees any signature it triggers. I would like for it to just be signature 1 for this and probably repeat for a signature 2
// Edit
Also it actually turns off when it sees a signature so not quite sure what I did.

RE: I'm a having a little trouble coding - Added by Drew Kern 7 days ago

pixy.init();
interrupts the digitalWrite command for the code I narrowed it down by writing
//
#include <SPI.h>
#include <Pixy.h>

// This is the main Pixy object
Pixy pixy;

void setup() {
pixy.init();
pinMode (13, OUTPUT);
pinMode (12, OUTPUT);
}

void loop() {
static int i = 0;
int j;
char buf32;
digitalWrite (13, HIGH);
digitalWrite (12, HIGH);
}
vs
//
#include <SPI.h>
#include <Pixy.h>

// This is the main Pixy object
Pixy pixy;

void setup() {
pinMode (13, OUTPUT);
pinMode (12, OUTPUT);
}

void loop() {
static int i = 0;
int j;
char buf32;
digitalWrite (13, HIGH);
digitalWrite (12, HIGH);
}
and in the bottom code both LED light up

(1-4/4)