Digistump Forums
The Digispark => Digispark Pro Support => Topic started by: jwhendy on April 02, 2016, 07:53:28 am
-
Hello,
I believe I followed the instructions on DigiCDC (https://digistump.com/wiki/digispark/tutorials/digicdc) correctly, but am having issues reading via the serial monitor. I opened up Examples -> DigiSparkCDC -> Echo and it works as I'd expect. Whatever I send is then printed out in the serial monitor. Reading, however, only seems to start to send, then stops. See the attached screenshot of what I get when running Examples -> DigiSparkCDC -> Print.
I started troubleshooting this when attempting to see if the Digispark Pro would work with an ADXL345 accelerometer I have. I modified my code, which successfully reads all three axes on an Arduino Uno to contain the following modified/extra code:
#include <Wire.h>
#include <DigiCDC.h>
// bunch of setup code for adxl
int x = 0;
long now = millis();
void setup() {
// join i2c bus (address optional for master)
Wire.begin();
SerialUSB.begin();
}
void loop() {
if(millis() - now > 100)
{
//read the acceleration data from the ADXL345
// this is defined elsewhere; omitting for brevity's sake
readFrom(DATAX0, howManyBytesToRead, _buff);
x = (((int)_buff[1]) << 8) | _buff[0];
// this is the actual code I want to use; I replaced with just printing
// a string to test SerialUSB, which is when I found it didn't work
// SerialUSB.println(x);
SerialUSB.print(F("123"));
now = millis();
}
// have tried each and both of these in case my cycle wasn't < 10ms
// SerialUSB.refresh();
// SerialUSB.delay(1);
}
Anything look out of place? I'm more interested in why the Print example wouldn't work. Thanks for any suggestions!