Hi, I am trying to use the Grove EMG detector to give readings about muscle activity/use an LED, but I can't install the demo code shown on the detector site.
The error message I'm getting is
Error: Request installZip failed with message: 13 INTERNAL: Library install failed: library not valid
and this is where I found the demo code.
I've looked elsewhere for other zip libraries that I might be able to download, but I haven't been able to find any yet.
I appreciate your help, but Im still having problems with the code. I downloaded the Grove LED library and included that into the demo code, but when I upload, Im getting this error message:
// Grove - EMG Sensor demo code
// This demo will need a Grove - Led Bar to show the motion
// Grove - EMG Sensor connect to A0
// Grove - LED Bar connect to D8, D9
// note: it'll take about serval seconds to detect static analog value
// when you should hold your muscle static. You will see led bar from level 10 turn to
// level 0, it means static analog value get ok
#include <Grove_LED_Bar.h>
Grove_LED_Bar bar(9, 8);
int max_analog_dta = 300; // max analog data
int min_analog_dta = 100; // min analog data
int static_analog_dta = 0; // static analog data
// get analog value
int getAnalog(int pin)
{
long sum = 0;
for(int i=0; i<32; i++)
{
sum += analogRead(pin);
}
int dta = sum>>5;
max_analog_dta = dta>max_analog_dta ? dta : max_analog_dta; // if max data
min_analog_dta = min_analog_dta>dta ? dta : min_analog_dta; // if min data
return sum>>5;
}
void setup()
{
Serial.begin(115200);
long sum = 0;
for(int i=0; i<=10; i++)
{
for(int j=0; j<100; j++)
{
sum += getAnalog(A0);
delay(1);
}
bar.setLevel(10-i);
}
sum /= 1100;
static_analog_dta = sum;
Serial.print("static_analog_dta = ");
Serial.println(static_analog_dta);
}
int level = 5;
int level_buf = 5;
void loop()
{
int val = getAnalog(A0); // get Analog value
int level2;
if(val>static_analog_dta) // larger than static_analog_dta
{
level2 = 5 + map(val, static_analog_dta, max_analog_dta, 0, 5);
}
else
{
level2 = 5 - map(val, min_analog_dta, static_analog_dta, 0, 5);
}
// to smooth the change of led bar
if(level2 > level)
{
level++;
}
else if(level2 < level)
{
level--;
}
if(level != level_buf)
{
level_buf = level;
bar.setLevel(level);
}
delay(10);
}
Hi @madeleinemc20. You need to install the "Grove LED Bar" library. I'll provide instructions for doing that:
Select Sketch > Include Library > Manage Libraries... from the Arduino IDE menus to open the "Library Manager" view in the left side panel.
In the "Filter your search" field, type Grove LED Bar
Scroll down through the list of libraries until you see the "Grove LED Bar" entry.
You will see an "INSTALL" button at the bottom of the entry. Click the button.
Wait for the installation to finish.
It seem your code is written for a very old version of the library, so it will not compile for the modern version you just installed. You can study the example sketches that are available from the File > Examples > Grove LED Bar menu in Arduino IDE to learn the correct way to use the library.
Hi, apologies, I've already done this step and downloaded and included the library - and I used the example sketches and discovered that the library needed to be included as 'GROVE_LED_Bar' not just 'LED_Bar' so I changed it. The issue is that when I run this code with the downloaded library for the LED bar and the updated code, the system still has an issue with that line of code. When I use
#include <Grove_LED-Bar.h>
in the example sketches it works fine. I was just wondering why it wasn't working on this code.
All I'm aiming for is to get some kind of reading from the EMG sensors, it doesn't even have to include the LED bar.
The library I instructed you to install does not contain a file named Grove_LED-Bar.h, so you must have installed some other library with a file of that name. The library I instructed you to install has a file named ``Grove_LED_Bar.h(notice the_instead of-). I didn't find any reference anywhere on the internet to a file named Grove_LED-Bar.h`, so I can't provide any more specific answer about this.
I think it will be a good idea to remove any unnecessary complexity from your sketch at this point in the project. That includes the LED bar.
You should remove all code related to the LED bar from your sketch and instead simply print the reading from the EMG sensors to the Arduino IDE Serial Monitor.
There is some information about printing things to Serial Monitor here:
apologies, I mistyped that the file is in fact Grove_LED_Bar.h
I agree that it is probably best to remove the LED bar, but I feel pretty unsure on how to write this code. Would you recommend the Arduino reference as the best place to learn this?