error compiling
i new arduino , programming, , have friend needs building arduino powered solenoid driver precisely control drops of kyoto-style cold coffee brewer, video of talking https://youtu.be/q5ww_9ztyge. we got parts when tried upload program got error
/users/franciscofernandez/desktop/arduino/sketch_jul22a/sketch_jul22a.ino:2:31: fatal error: adafruit_mcp23017.h: no such file or directory
#include <adafruit_mcp23017.h>
^
compilation terminated.
exit status 1
error compiling board arduino/genuino uno.
this code.......
/users/franciscofernandez/desktop/arduino/sketch_jul22a/sketch_jul22a.ino:2:31: fatal error: adafruit_mcp23017.h: no such file or directory
#include <adafruit_mcp23017.h>
^
compilation terminated.
exit status 1
error compiling board arduino/genuino uno.
this code.......
code: [select]
#include <wire.h>
#include <adafruit_mcp23017.h>
#include <adafruit_rgblcdshield.h>
#include <adafruit_motorshield.h>
#include "utility/adafruit_pwmservodriver.h"
#include <servo.h>
// shield uses i2c scl , sda pins. on classic arduinos
// analog 4 , 5 can't use analogread() anymore
// however, can connect other i2c sensors i2c bus , share
// i2c bus.
adafruit_rgblcdshield lcd = adafruit_rgblcdshield();
// these #defines make easy set backlight color
#define red 0x1
#define yellow 0x3
#define green 0x2
#define teal 0x6
#define blue 0x4
#define violet 0x5
#define white 0x7
// create motor shield object default i2c address
adafruit_motorshield afms = adafruit_motorshield();
// connect stepper motor 200 steps per revolution (1.8 degree)
// motor port #2 (m3 , m4)
adafruit_steppermotor *mystepper = afms.getstepper(200, 2);
// , connect dc motors ports
adafruit_dcmotor *mymotor1 = afms.getmotor(1);
adafruit_dcmotor *mymotor2 = afms.getmotor(2);
adafruit_dcmotor *mymotor3 = afms.getmotor(3);
adafruit_dcmotor *mymotor4 = afms.getmotor(4);
int t_drop = 50;
int t_calib_1 = 0, t_calib_2 = 0;
int t_delay = 1000;
int t_enable = 0;
void runmotor(int motor) {
if(motor == 1) {
mymotor1->run(forward);
mymotor3->run(forward);
} else {
mymotor2->run(forward);
mymotor4->run(forward);
}
}
void stopmotor(int motor) {
if(motor == 1) {
mymotor1->run(release);
mymotor3->run(release);
} else {
mymotor2->run(release);
mymotor4->run(release);
}
}
void update() {
lcd.clear();
lcd.setcursor(0, 0);
lcd.print("drop: ");
lcd.print(t_drop);
if(t_enable == 1) {
lcd.print("+");
lcd.print(t_calib_1);
} else if(t_enable == 2) {
lcd.print("+");
lcd.print(t_calib_2);
}
lcd.print(" msec");
lcd.setcursor(0, 1);
lcd.print("rate: ");
lcd.print(t_delay/500);
lcd.print(".");
lcd.print((t_delay/50)%10);
lcd.print(" sec ");
lcd.print(t_enable);
}
void setup() {
int i, test = 1;
uint8_t button, button_last = 0;
serial.begin(9600); // set serial library @ 9600 bps
// set lcd's number of columns , rows:
lcd.begin(16, 2);
lcd.setbacklight(white);
afms.begin(); // create default frequency 1.6khz
// turn on motor m1
mymotor1->setspeed(255);
mymotor1->run(release);
mymotor2->setspeed(255);
mymotor2->run(release);
mymotor3->setspeed(255);
mymotor3->run(release);
mymotor4->setspeed(255);
mymotor4->run(release);
// wait max chip stabilize
delay(500);
if(lcd.readbuttons() == button_select) {
lcd.clear();
lcd.setcursor(0, 0);
lcd.print("calibration");
delay(2000);
while(1) {
while(1) {
lcd.setcursor(0, 1);
lcd.print("1=");
lcd.print(t_calib_1);
if(test == 1) lcd.print("* ");
else lcd.print(" ");
lcd.setcursor(8, 1);
lcd.print("2=");
lcd.print(t_calib_2);
if(test == 2) lcd.print("* ");
else lcd.print(" ");
button = lcd.readbuttons();
if(button != button_last) {
if(button == button_right) {
if(test == 1) test = 2;
else test = 1;
}
if(button == button_left) {
for(i = 0; < 100; i++) {
runmotor(test);
delay(50 + ((test == 1) ? t_calib_1 : t_calib_2));
stopmotor(test);
delay(150);
}
}
if(button == button_up) {
if(test == 1) t_calib_1++;
else t_calib_2++;
}
if(button == button_down)
if(test == 1) t_calib_1--;
else t_calib_2--;
if(button == button_select)
goto done;
}
button_last = button;
delay(100);
}
}
}
done:
update();
}
int timer = 0, motor = 0;
void loop() {
uint8_t buttons = lcd.readbuttons();
static uint8_t buttons_last;
if(buttons && (buttons != buttons_last)) {
if(buttons & button_up) {
if((t_enable == 3) || (t_enable == 0))
t_drop += 10;
else if(t_enable == 1)
t_calib_1++;
else if(t_enable == 2)
t_calib_2++;
}
if(buttons & button_down) {
if((t_enable == 3) || (t_enable == 0))
t_drop -= 10;
else if(t_enable == 1)
t_calib_1--;
else if(t_enable == 2)
t_calib_2--;
}
if(buttons & button_right) {
t_delay += 100;
}
if(buttons & button_left) {
t_delay -= 100;
}
if(buttons & button_select) {
if(!t_enable) t_enable = 3;
else t_enable--;
stopmotor(1);
stopmotor(2);
}
update();
timer = 0;
}
buttons_last = buttons;
if(timer == 0) {
if(!motor && (t_enable & 1)) {
runmotor(1);
delay(t_drop + t_calib_1);
stopmotor(1);
timer += t_drop + t_calib_1;
} else if(motor && (t_enable & 2)) {
runmotor(2);
delay(t_drop + t_calib_2);
stopmotor(2);
timer += t_drop + t_calib_1;
}
}
delay(8);
timer += 10;
if(timer >= t_delay) {
timer = 0;
motor++;
motor &= 1;
}
}
have downloaded , installed "adafruit_mcp23017" library?
incidentally, don't post code inline. please use [code]// code tags[/code].
you can select code press </> button in edit window.
also, don't add characters '+' have @ start of each line. wanting copy code , paste ide testing has manually remove each , every '+' before can test code.
(it's not late edit post , make these corrections;) )
edit: library here:- adafruit-mcp23017-arduino-library
incidentally, don't post code inline. please use [code]// code tags[/code].
you can select code press </> button in edit window.
also, don't add characters '+' have @ start of each line. wanting copy code , paste ide testing has manually remove each , every '+' before can test code.
(it's not late edit post , make these corrections;) )
edit: library here:- adafruit-mcp23017-arduino-library
Arduino Forum > Using Arduino > Installation & Troubleshooting > error compiling
arduino
Comments
Post a Comment