'hexy' was not declared in this scope

When I put this code in the Arduino IDE, the error “‘hexy’ was not declared in this scope”, please help me !!

#include <avr/pgmspace.h>
#define MOVE_HEXY_SIZE 0

const PROGMEM uint16_t move_hexy_time[MOVE_HEXY_SIZE] = {
};

const PROGMEM uint8_t move_hexy_servo[MOVE_HEXY_SIZE] = {
};

const PROGMEM uint8_t move_hexy_pos[MOVE_HEXY_SIZE] = {
};

void move_hexy() {
int startTime = hexy.millis_new(); <---------------
int currentTime = 0;
int last_update = 0;
for (int i = 0; i < MOVE_HEXY_SIZE; i++) {
delayMicroseconds(10);
currentTime = hexy.millis_new() - startTime;
uint16_t move_time = pgm_read_word_near(move_hexy_time + i);
while (currentTime < move_time) {
delayMicroseconds(10);
currentTime = hexy.millis_new() - startTime;
}
uint8_t servo_time = pgm_read_byte_near(move_hexy_servo + i);
uint8_t servo_pos = pgm_read_byte_near(move_hexy_pos + i);
hexy.changeServo(servo_time, servo_pos * 10);
last_update = currentTime;
}
}
//Move Size is 0 bytes
//Run this move by using:
// move_hexy()

It will not be possible for us to help you from so little information. Presumably you found this code somewhere. Don't you think it would be helpful to tell us where you found it?

I'm setting up a robot like Arcbotics Hexy . To use it with arduino, I needed the software PoMoCo 2.0, it generates the code for arduino. PoMoCo generates movements in a "virtual robot" and converts them to the arduino code. I tried to change the code but the error remains.

That code you posted is not all of your code, is it? If it is, you need to dump that crap software that generated it.

this code is to make only one servo motor work, but not to take advantage of it?

Your code uses an object named 'hexy':

int startTime = hexy.millis_new();

Where have you defined that object?

for me to speak the truth I do not know much about arduino, so I downloaded this program, but I think it is defined at the beginning of the code

So perhaps it would be a good idea to post ALL your code, don't you think?

BTW, it doesn't matter you got it, it's your project and your code now. So, you're gonna have to step up and do some work - starting with helping people who are (currently) willing to help you for free. Do that by giving all the information possible at the beginning.

But that's the whole project. is just a test, to move the servomotor a bit. Just to test this code, it is configured to move a single servomotor.

If you want to do a test of moving the servo then you can get started with File > Examples > Servo > Sweep and the accompanying tutorial:

It worked, but now I need to move the whole theft, there are 18 servomotors, this is the complete code:

#include <avr/pgmspace.h>
#define MOVE_HEXY_SIZE 264

const PROGMEM uint16_t move_hexy_time[MOVE_HEXY_SIZE] = {
0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 4, 4, 4, 4, 5, 5, 9, 10, 10, 11, 11, 11, 11, 12, 166, 166, 167, 167, 168, 168, 168, 169, 169, 170, 170, 170, 171, 171, 171, 171, 172, 172, 334, 334, 335, 335, 335, 336, 337, 337, 337, 338, 338, 338, 339, 339, 339, 339, 340, 340, 612, 612, 613, 614, 615, 616, 617, 618, 618, 619, 619, 619, 619, 620, 620, 620, 620, 620, 621, 621, 621, 621, 621, 622, 622, 622, 622, 622, 623, 623, 783, 784, 784, 784, 784, 784, 793, 793, 793, 794, 797, 797, 797, 797, 797, 797, 797, 797, 950, 950, 950, 950, 951, 951, 954, 954, 954, 954, 955, 955, 956, 956, 956, 956, 957, 957, 1223, 1224, 1224, 1225, 1225, 1226, 1227, 1228, 1229, 1229, 1230, 1230, 1230, 1230, 1231, 1231, 1231, 1231, 1231, 1232, 1232, 1232, 1232, 1232, 1233, 1233, 1233, 1233, 1233, 1233, 1387, 1387, 1388, 1388, 1388, 1388, 1395, 1395, 1396, 1396, 1396, 1397, 1397, 1398, 1398, 1398, 1398, 1399, 1555, 1555, 1556, 1556, 1556, 1557, 1563, 1563, 1564, 1564, 1564, 1564, 1565, 1565, 1566, 1566, 1566, 1566, 1830, 1831, 1831, 1832, 1833, 1834, 1834, 1835, 1836, 1836, 1837, 1837, 1837, 1837, 1838, 1838, 1838, 1838, 1839, 1839, 1839, 1839, 1839, 1840, 1840, 1840, 1843, 1843, 1844, 1844, 2000, 2001, 2001, 2002, 2002, 2002, 2002, 2003, 2003, 2003, 2004, 2004, 2004, 2005, 2005, 2005, 2006, 2006, 2168, 2168, 2168, 2168, 2168, 2168, 2171, 2171, 2172, 2172, 2172, 2172, 2173, 2173, 2173, 2174, 2174, 2174};

const PROGMEM uint8_t move_hexy_servo[MOVE_HEXY_SIZE] = {
6, 6, 5, 5, 7, 7, 21, 21, 22, 22, 20, 20, 14, 14, 13, 13, 15, 15, 24, 24, 24, 24, 11, 11, 11, 16, 11, 16, 16, 16, 6, 6, 5, 5, 21, 7, 21, 7, 22, 22, 14, 20, 14, 20, 13, 13, 15, 15, 6, 6, 5, 5, 7, 7, 21, 21, 22, 22, 20, 14, 20, 14, 13, 13, 15, 15, 25, 25, 10, 26, 10, 26, 17, 9, 24, 7, 17, 9, 24, 7, 18, 20, 11, 7, 18, 15, 20, 11, 7, 16, 15, 20, 16, 15, 20, 15, 25, 25, 26, 26, 24, 24, 10, 10, 9, 9, 17, 11, 17, 11, 18, 18, 16, 16, 25, 25, 26, 26, 24, 24, 10, 10, 9, 9, 17, 11, 17, 11, 18, 18, 16, 16, 6, 6, 5, 5, 7, 7, 21, 21, 22, 14, 22, 14, 24, 13, 20, 24, 13, 11, 20, 15, 24, 11, 16, 15, 24, 11, 16, 11, 16, 16, 6, 6, 5, 5, 7, 7, 21, 21, 22, 22, 20, 14, 20, 14, 13, 13, 15, 15, 6, 6, 5, 5, 7, 7, 21, 21, 22, 22, 20, 20, 14, 14, 13, 13, 15, 15, 25, 25, 26, 10, 26, 10, 24, 17, 9, 24, 17, 7, 9, 18, 7, 11, 18, 7, 11, 20, 16, 7, 20, 16, 20, 20, 15, 15, 15, 15, 25, 25, 26, 26, 24, 24, 10, 10, 9, 9, 11, 17, 11, 17, 18, 18, 16, 16, 25, 25, 26, 26, 24, 24, 10, 10, 9, 9, 11, 11, 17, 17, 18, 18, 16, 16};

const PROGMEM uint8_t move_hexy_pos[MOVE_HEXY_SIZE] = {
150 , 209 , 150 , 109 , 150 , 150 , 150 , 156 , 150 , 56 , 150 , 159 , 150 , 156 , 150 , 56 , 150 , 131 , 150 , 94 , 94 , 94 , 150 , 177 , 177 , 150 , 177 , 150 , 150 , 150 , 209 , 209 , 109 , 109 , 156 , 150 , 156 , 150 , 56 , 56 , 156 , 159 , 156 , 168 , 56 , 56 , 131 , 113 , 209 , 209 , 109 , 109 , 150 , 150 , 156 , 209 , 56 , 109 , 168 , 156 , 177 , 209 , 56 , 109 , 113 , 94 , 150 , 156 , 150 , 150 , 156 , 56 , 150 , 150 , 94 , 150 , 156 , 56 , 113 , 205 , 150 , 177 , 177 , 205 , 56 , 94 , 122 , 159 , 205 , 150 , 150 , 122 , 168 , 150 , 122 , 150 , 156 , 156 , 56 , 56 , 113 , 131 , 156 , 156 , 56 , 56 , 156 , 159 , 156 , 140 , 56 , 56 , 168 , 187 , 156 , 209 , 56 , 109 , 131 , 150 , 156 , 209 , 56 , 109 , 156 , 140 , 209 , 122 , 56 , 109 , 187 , 205 , 209 , 156 , 109 , 56 , 205 , 187 , 209 , 156 , 109 , 209 , 56 , 156 , 150 , 109 , 122 , 94 , 56 , 122 , 140 , 150 , 94 , 177 , 205 , 131 , 94 , 177 , 150 , 177 , 150 , 150 , 156 , 156 , 56 , 56 , 187 , 168 , 156 , 156 , 56 , 56 , 140 , 156 , 159 , 156 , 56 , 56 , 131 , 113 , 156 , 209 , 56 , 109 , 168 , 150 , 156 , 209 , 56 , 109 , 159 , 177 , 156 , 209 , 56 , 109 , 113 , 94 , 209 , 156 , 109 , 209 , 56 , 156 , 94 , 209 , 109 , 113 , 156 , 150 , 56 , 109 , 205 , 177 , 56 , 205 , 159 , 177 , 150 , 205 , 122 , 168 , 122 , 122 , 94 , 150 , 150 , 150 , 156 , 156 , 56 , 56 , 113 , 131 , 156 , 156 , 56 , 56 , 159 , 156 , 140 , 156 , 56 , 56 , 168 , 187 , 156 , 209 , 56 , 109 , 131 , 150 , 156 , 209 , 56 , 109 , 140 , 122 , 156 , 209 , 56 , 109 , 187 , 205 };

void move_hexy(){
int startTime = hexy.millis_new(); <----------
int currentTime = 0;
int last_update = 0;
for(int i=0; i<MOVE_HEXY_SIZE; i++){
delayMicroseconds(10);
currentTime = hexy.millis_new() - startTime;
uint16_t move_time = pgm_read_word_near(move_hexy_time + i);
while(currentTime < move_time){
delayMicroseconds(10);
currentTime = hexy.millis_new() - startTime;
}
uint8_t servo_time = pgm_read_byte_near(move_hexy_servo + i);
uint8_t servo_pos = pgm_read_byte_near(move_hexy_pos + i);
hexy.changeServo(servo_time, servo_pos*10);
last_update = currentTime;
}
}
//Move Size is 1056 bytes
//Run this move by using:
// move_hexy()

this is for robot to move forward, but the error continues to appear, you know if there is a way, and how to fix it?

Please use code tags (</> button on the toolbar) when you post code or error/warning output, not the table markup.

guinser:
this is the complete code:

The problem is that’s not a complete program. So either the PoMoCo 2.0 is not working correctly, or more likely you’re not properly following the instructions for how to use it.

The hexy object is still not defined anywhere

What happened to

#include "Servotor32.h" // call the servotor32 Library
Servotor32 hexy; // create a servotor32 object

That the example code uses ?

UKHeliBob:
The hexy object is still not defined anywhere

What happened to

#include "Servotor32.h" // call the servotor32 Library

Servotor32 hexy; // create a servotor32 object



That the example code uses ?

setup() and loop() functions would be nice too.

UKHeliBob:
The hexy object is still not defined anywhere

What happened to

#include "Servotor32.h" // call the servotor32 Library

Servotor32 hexy; // create a servotor32 object



That the example code uses ?

at the time of generating the code, it does not create this function. Is this the problem?

guinser:
Is this the problem?

Apparently, since it's an incomplete program and won't compile.

How about checking out the ArcBotics website's forum. There are other people with the same issue.
Arduino Compiling Error

PoMoCo does not generate a complete program, just what you need to stick in your program.

They even show an example on the Generating Arduino Code page.

#include "Servotor32.h" // call the servotor32 Library
Servotor32 hexy; // create a servotor32 object
 
void setup() {
  hexy.begin();
}
 
void loop() {
  hexy.delay_ms(5000); // wait 5000mS, or 5s
 
  move_hexy();
 
}

roboalchemist

Feb '16

Hello,

The code is meant to be pasted at the bottom of the existing code (so it can have the hexy library already started at the top).

I had not really thought about it, thanks :smiley:
I just do not understand what it means to put the code at the bottom of the existing code, could you help me?

Something like the code in reply #16 then the code you have been trying after that

now this error appears
Arduino: 1.6.12 (Windows 8.1), Card: "Arduino / Genuine One"

The sketch uses 10,356 bytes (36%) of storage space for programs. The maximum is 28,672 bytes.
Global variables use 923 bytes (36%) of dynamic memory, leaving 1,637 bytes for local variables. The maximum is 2,560 bytes.
An error occurred while the sketch was loading