In the C file in simplesample_mqtt.c, which connects Arduino to the Azure IoT hub, I need to use the IRsend and IrRemoteESP8266 libraries to send an infrared signal with Azure IoT hub.
#include <IRremoteESP8266.h>
#include <IRsend.h>
IRsend irsend(10); // An IR LED is controlled by GPIO pin 4 (D2)
I don't have any problem when I use this code in my main Ardunio file. But when I use these includes in a C file (implesample_mqtt.c), I get this error from line 3: "unknown type name 'IRsend'".
error full info :
Arduino: 1.8.2 (Windows 10), Board: "NodeMCU 0.9 (ESP-12 Module), 80 MHz, 115200, 4M (3M SPIFFS)"
In file included from sketch\simplesample_mqtt.c:29:0:
C:\Program Files (x86)\Arduino\libraries\IRremoteESP8266\src/IRsend.h:29:1: error: unknown type name 'class'
class IRsend {
C:\Program Files (x86)\Arduino\libraries\IRremoteESP8266\src/IRsend.h:29:14: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
class IRsend {
simplesample_mqtt.c:31: error: unknown type name 'IRsend'
IRsend irsend(10); // An IR LED is controlled by GPIO pin 4 (D2)
simplesample_mqtt.c:31: error: expected declaration specifiers or '...' before numeric constant
IRsend irsend(10); // An IR LED is controlled by GPIO pin 4 (D2)
exit status 1
unknown type name 'IRsend'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I solved this problem. The reason for this is because main ardunio is c++ and simplesample_mqtt.c is c code and we have to use c++ code in c code :
i main ardunio file you have to declare function like this :
extern "C" void TurnOn();
void TurnOn()
{
digitalWrite(RELAY_SONOFF, HIGH);
digitalWrite(LED_SONOFF, HIGH);
}
and use this function in c code :
void TurnOn();
EXECUTE_COMMAND_RESULT TurnOn(ContosoAnemometer* device)
{
(void)device;
TurnOn();
(void)printf("Turning fan on.\r\n");
return EXECUTE_COMMAND_SUCCESS;
}
Related
i want to upload a Script to read out a Lightsensor i have bought. The Sensor is a Grove - Sunlightsensor and the libary for it can be found on GitHub.
The Board i am going to use is a WeMos D1 Mini using a ESP8266, but since many Pins are taken i want to use GPIO2 as SDA and 13 as SCL which can be achieved with: Wire.begin(2,13);
But the Pins are not relavant for compiling.
I want to try the example-script found in the libary from the producer:
#include "Si115X.h"
Si115X si1151;
/**
* Setup for configuration
*/
void setup()
{
uint8_t conf[4];
Wire.begin(2,13);
Serial.begin(115200);
if (!si1151.Begin())
Serial.println("Si1151 is not ready!");
else
Serial.println("Si1151 is ready!");
}
/**
* Loops and reads data from registers
*/
void loop()
{
Serial.print("IR: ");
Serial.println(si1151.ReadHalfWord());
Serial.print("VISIBLE: ");
Serial.println(si1151.ReadHalfWord_VISIBLE());
Serial.print("UV: ");
Serial.println(si1151.ReadHalfWord_UV());
delay(100);
}
But i get the following error massage:
c:\Users\nikol\Documents\Mechatronik_Projekte\Arduino_Sketches\libraries\Grove_Sunlight_Sensor-Si1151\Si115X.cpp: In member function 'int Si115X::read_register(uint8_t, uint8_t, int)':
c:\Users\nikol\Documents\Mechatronik_Projekte\Arduino_Sketches\libraries\Grove_Sunlight_Sensor-Si1151\Si115X.cpp:42:39: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
42 | Wire.requestFrom(addr, bytesOfData);
| ^
In file included from c:\Users\nikol\Documents\Mechatronik_Projekte\Arduino_Sketches\libraries\Grove_Sunlight_Sensor-Si1151\Si115X.h:5,
from c:\Users\nikol\Documents\Mechatronik_Projekte\Arduino_Sketches\libraries\Grove_Sunlight_Sensor-Si1151\Si115X.cpp:2:
C:\Users\nikol\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.1\libraries\Wire/Wire.h:73:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int)'
73 | uint8_t requestFrom(int, int);
| ^~~~~~~~~~~
C:\Users\nikol\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.1\libraries\Wire/Wire.h:71:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t)'
71 | uint8_t requestFrom(uint8_t, uint8_t);
| ^~~~~~~~~~~
c:/users/nikol/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\nikol\AppData\Local\Temp\arduino-sketch-5BFDDB9EDB939386E5CB1A13D5CC3F69\sketch\Si1151.ino.cpp.o: in function `setup':
C:\Users\nikol\AppData\Local\Temp\.arduinoIDE-unsaved2023112-24360-28iud3.owxco\Si1151/Si1151.ino:18: undefined reference to `_ZN6Si115X12ReadHalfWordEv'
c:/users/nikol/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\nikol\AppData\Local\Temp\.arduinoIDE-unsaved2023112-24360-28iud3.owxco\Si1151/Si1151.ino:18: undefined reference to `_ZN6Si115X20ReadHalfWord_VISIBLEEv'
c:/users/nikol/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\nikol\AppData\Local\Temp\arduino-sketch-5BFDDB9EDB939386E5CB1A13D5CC3F69\sketch\Si1151.ino.cpp.o:(.text.loop+0x14): undefined reference to `_ZN6Si115X15ReadHalfWord_UVEv'
c:/users/nikol/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\nikol\AppData\Local\Temp\arduino-sketch-5BFDDB9EDB939386E5CB1A13D5CC3F69\sketch\Si1151.ino.cpp.o:(.text.loop+0x3a): undefined reference to `_ZN6Si115X12ReadHalfWordEv'
c:/users/nikol/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\nikol\AppData\Local\Temp\arduino-sketch-5BFDDB9EDB939386E5CB1A13D5CC3F69\sketch\Si1151.ino.cpp.o: in function `loop':
C:\Users\nikol\AppData\Local\Temp\.arduinoIDE-unsaved2023112-24360-28iud3.owxco\Si1151/Si1151.ino:27: undefined reference to `_ZN6Si115X20ReadHalfWord_VISIBLEEv'
c:/users/nikol/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\nikol\AppData\Local\Temp\.arduinoIDE-unsaved2023112-24360-28iud3.owxco\Si1151/Si1151.ino:28: undefined reference to `_ZN6Si115X15ReadHalfWord_UVEv'
collect2.exe: error: ld returned 1 exit status
exit status 1
Compilation error: exit status 1
I already tried using a different compilerversion (2.7.4) but the same error accured.
I might be wrong and not expirienced but the error output seems that something is messed up in the libary itselfe?
Thanks for any help. If further information is needed i am happy to give it to you.
I'm the owner the Digispark micro and gm009605v4 OLED display. But I'm not able compile this project
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_Address 0x3C
Adafruit_SSD1306 oled(1);
void setup() {
oled.begin(SSD1306_SWITCHCAPVCC, OLED_Address);
}
void loop() {
oled.clearDisplay();
oled.setTextColor(WHITE);
oled.setCursor(0,0);
oled.println("Hello!");
oled.display();
}
The error message is
Arduino: 1.8.12 (Windows 10), Board: "Digispark (Default - 16.5mhz)"
In file included from C:\Users\lin\Documents\Arduino\sketch_jun11a\sketch_jun11a.ino:1:0:
C:\Users\lin\Documents\Arduino\libraries\Adafruit-GFX-Library-master/Adafruit_GFX.h:113:28: error: '__FlashStringHelper' does not name a type
void getTextBounds(const __FlashStringHelper *s, int16_t x, int16_t y,
^
C:\Users\lin\Documents\Arduino\libraries\Adafruit-GFX-Library-master/Adafruit_GFX.h:113:49: error: ISO C++ forbids declaration of 's' with no type [-fpermissive]
void getTextBounds(const __FlashStringHelper *s, int16_t x, int16_t y,
^
In file included from c:\users\lin\appdata\local\arduino15\packages\arduino\tools\avr-gcc\4.8.1-arduino5\avr\include\avr\io.h:99:0,
from c:\users\lin\appdata\local\arduino15\packages\arduino\tools\avr-gcc\4.8.1-arduino5\avr\include\avr\interrupt.h:38,
from C:\Users\lin\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/WProgram.h:8,
from C:\Users\lin\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/Arduino.h:4,
from sketch\sketch_jun11a.ino.cpp:1:
And more....
Can you help me, please? I have installed latest Adafruit SSD1306. Or is there another library for work with this display? Noone example I found and tried worked for me
Adafruit has stated the following:
It will compile if you set the processor to digispark pro.
Why it is that way is known to them.
EDIT: The problem was solved - New problem TwoWire does not name a type. Solution for that:
The adafruit library is directly referencing the TwoWire class which is normally defined in wire.h. For the Digistump boards, they have a similar class but it is called WUI_TWI, not TwoWire.
Probably the easiest way to fix this would be to modify the wire.h file that came from Digistump. add this near the end of the file wire.h
extern USI_TWI Wire;
#define TwoWire USI_TWI // add this line
#endif
The wire.h file (in windows) will be located in
C:\Users\YOUR_USERNAME\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\libraries\Wire
make sure it is this one for digistump with the USI_TWI class, not the standard arduino one with the TwoWire class
I am trying to interface with the MPU-6050 as part of a robotics project using the Texas Instruments TM4C123G LaunchPad. I am uploading code onto this from Energia and am using the serial monitor to see the raw data output, however I am only receiving the following output when I upload it to the micro controller and run it:
Initialising I2C devices...
Here is the code that I am trying to run:
#include <Wire.h>
#include <I2Cdev.h>
#include <MPU6050.h>
MPU6050 accelgyro;
void Setup_MPU6050()
{
Wire.begin();
Serial.println("Initialising I2C devices...");
accelgyro.initialize();
Serial.println("Testing device connections...");
Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");
}
void Update_MPU6050()
{
int16_t ax, ay, az;
int16_t gx, gy, gz;
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
Serial.print("i");Serial.print("\t");
Serial.print(ax);Serial.print("\t");
Serial.print(ay);Serial.print("\t");
Serial.print(az);Serial.print("\t");
Serial.print(gx);Serial.print("\t");
Serial.print(gy);Serial.print("\t");
Serial.println(gz);
Serial.print("\n");
}
void setup()
{
Serial.begin(115200);
Setup_MPU6050();
}
void loop()
{
Update_MPU6050();
}
The pins on the breakout board are connected to the Launchpad as follows:
VDD -> Pin 1 (3.3v)
GND -> Pin 12 (GND)
INT -> Pin 34 (PF0)
FSYNC -> None
SCL -> Pin 13 (PD0)
SDA - > Pin 14 (PD1)
VIO -> None
CLK -> None
ASCL -> None
ASDA -> None
I have got the MPU6050 and I2Cdev libraries from GitHub and have got the Wire library from github.com/codebendercc/arduino-library-files/blob/master/libraries/Wire/Wire.h but am thinking that either the wire.begin() or accelgyro.initialize() methods are not functioning properly? I am a relative beginner when it comes to programming in this language but I am undertaking an ambitious task to create a robot for a scholarship that I am applying for, and would therefore appreciate some assistance on this subject area.
I just met the same question as you. Here is a useful linkage:
enter link description here
I referred it and added some code before
Wire.begin()
--just like this
enter image description here
then I upload it and run, it works perfectly. And there is another thing to be minded that you can't connect INT pin when you don't use DMP but when you use DMP then you must connect INT pin.
I try to explain it.
Why should we add the two lines codes? The Library is from Arduino, although Energia is compatible with Arduino programming in most cases but not always. So we should explictly acclaim something.
And why should we pay attention the interruption. Because when we use DMP we use it, if we don't connect the INT pin, it willn't work normally.
I have recently installed MS Visual Studio 2015 with the Arduino plugin "Visual Micro".
Everything works fine, upload a sketch etc. Except when I try to compile my code when I use FreeRTOS. I downloaded the FreeRTOS libary through the Arduino IDE (library manager). Therefore(in MS VS 2015) I could chose to include the library in MS VS 2015. So I included the library in one of my sketches. Below you see my code example. Within the Arduino IDE i can compile the code and upload it to the device, but in MS VS there are some errors.
#include <timers.h>
#include <task.h>
#include <StackMacros.h>
#include <semphr.h>
#include <queue.h>
#include <projdefs.h>
#include <portmacro.h>
#include <portable.h>
#include <mpu_wrappers.h>
#include <list.h>
#include <FreeRTOSVariant.h>
#include <FreeRTOSConfig.h>
#include <event_groups.h>
#include <croutine.h>
#include <Arduino_FreeRTOS.h>
//define Tasks
void TaskBlinkSlow(void *pvParameters);
void TaskBlinkFast(void *pvParameters);
void setup()
{
/* add setup code here */
xTaskCreate(TaskBlinkSlow, "TaskSlow", 128, NULL, 1, NULL);
xTaskCreate(TaskBlinkFast, "TaskFast", 128, NULL, 2, NULL);
pinMode(13, OUTPUT);
}
void loop()
{
//Empty, things are done in tasks!!!
}
void TaskBlinkSlow(void * pvParameters)
{
for (;;) {
for (int i = 0; i < 8; i++) {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
vTaskDelay(5000 / portTICK_PERIOD_MS);
}
}
void TaskBlinkFast(void * pvParameters)
{
for (;;) {
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500);
}
}
At the end of this post you will find the short snippet of the compilers error log. Maybe someone already came around the same issue and has a quick fix.
An example debugger breakpoint has been created. To switch the demo
breakpoint off, deselect Visual Micro>Tutorial Mode.
Compiling debug version of 'FreeRTOS' for 'Arduino/Genuino Uno'
FreeRTOS.ino:In file included from timers.h:75:3: error: #error
"include Arduino_FreeRTOS.h must appear in source files before include
timers.h" :#error "include Arduino_FreeRTOS.h must appear in source
files before include timers.h" timers.h:In file included from
FreeRTOS.ino:from task.h:75:3: error: #error "include
Arduino_FreeRTOS.h must appear in source files before include task.h"
:#error "include Arduino_FreeRTOS.h must appear in source files before
include task.h" task.h:In file included from timers.h:from
FreeRTOS.ino:from list.h:99:3: error: #error Arduino_FreeRTOS.h must
be included before list.h :#error Arduino_FreeRTOS.h must be included
before list.h FreeRTOS.ino:In file included from semphr.h:74:3: error:
error "include Arduino_FreeRTOS.h" must appear in source files before "include semphr.h" :#error "include Arduino_FreeRTOS.h" must appear in
source files before "include semphr.h" semphr.h:In file included from
FreeRTOS.ino:from queue.h:75:3: error: #error "include
Arduino_FreeRTOS.h" must appear in source files before "include
queue.h" :#error "include Arduino_FreeRTOS.h" must appear in source
files before "include queue.h" FreeRTOS.ino:In file included from
list.h:99:3: error: #error Arduino_FreeRTOS.h must be included before
list.h :#error Arduino_FreeRTOS.h must be included before list.h
task.h:In file included from timers.h:from FreeRTOS.ino:from
list.h:184:22: error: 'TickType_t' does not name a type
:configLIST_VOLATILE TickType_t xItemValue; *< The value being
listed. In most cases this is used to sort the list in descending
order. * list.h:196:22: error: 'TickType_t' does not name a type
:configLIST_VOLATILE TickType_t xItemValue list.h:208:22: error:
'UBaseType_t' does not name a type :configLIST_VOLATILE UBaseType_t
uxNumberOfItems list.h:386:47: error: expected initializer before
'PRIVILEGED_FUNCTION :void vListInitialise( List_t * const pxList )
PRIVILEGED_FUNCTION list.h:397:55: error: expected initializer before
'PRIVILEGED_FUNCTION :void vListInitialiseItem( ListItem_t * const
pxItem ) PRIVILEGED_FUNCTION list.h:410:77: error: expected
initializer before 'PRIVILEGED_FUNCTION :void vListInsert( List_t *
const pxList, ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION
list.h:431:80: error: expected initializer before 'PRIVILEGED_FUNCTION
:void vListInsertEnd( List_t * const pxList, ListItem_t * const
pxNewListItem ) PRIVILEGED_FUNCTION list.h:446:1: error: 'UBaseType_t'
does not name a type :UBaseType_t uxListRemove( ListItem_t * const
pxItemToRemove ) PRIVILEGED_FUNCTION timers.h:In file included from
FreeRTOS.ino:from task.h:109:20: error: ISO C++ forbids declaration of
'BaseType_t' with no type [-fpermissive] :typedef BaseType_t
(*TaskHookFunction_t)( void * ) task.h:109:20: error: typedef
'BaseType_t' is initialized (use decltype instead) task.h:109:22:
error: 'TaskHookFunction_t' was not declared in this scope :typedef
BaseType_t (*TaskHookFunction_t)( void * ) timers.h:In file included
from FreeRTOS.ino:from task.h:136:2: error: 'BaseType_t' does not name
a type :BaseType_t xOverflowCount task.h:137:2: error: 'TickType_t'
does not name a type :TickType_t xTimeOnEntering task.h:146:2: error:
'uint32_t' does not name a type :uint32_t ulLengthInBytes
task.h:147:2: error: 'uint32_t' does not name a type :uint32_t
ulParameters task.h:155:2: error: 'TaskFunction_t' does not name a
type :TaskFunction_t pvTaskCode task.h:157:2: error: 'uint16_t' does
not name a type :uint16_t usStackDepth task.h:159:2: error:
'UBaseType_t' does not name a type :UBaseType_t uxPriority
task.h:160:2: error: 'StackType_t' does not name a type :StackType_t
*puxStackBuffer task.h:161:27: error: 'portNUM_CONFIGURABLE_REGIONS' was not declared in this scope :MemoryRegion_t xRegions[
portNUM_CONFIGURABLE_REGIONS ] task.h:170:2: error: 'UBaseType_t' does
not name a type :UBaseType_t xTaskNumber; * A number unique to the
task. * task.h:172:2: error: 'UBaseType_t' does not name a type
:UBaseType_t uxCurrentPriority; * The priority at which the task was
running (may be inherited) when the structure was populated. *
task.h:173:2: error: 'UBaseType_t' does not name a type :UBaseType_t
uxBasePriority; * The priority to which the task will return if the
task's current priority has been inherited to avoid unbounded priority
inversion when obtaining a mutex. Only valid if configUSE_MUTEXES is
defined as 1 in FreeRTOSConfig.h. * timers.h:In file include
If you read the error messages, the issue is explained clearly.
include Arduino_FreeRTOS.h must appear first.
Your example shows it included last.
Put it first and the errors will go away.
Arduino_FreeRTOS.h includes many definitions that are used in other places, hence the need for it to be first.
Unrelated to your question, but using delay() is nasty as it consumes CPU cycles needlessly. Try vTaskDelay() as alternative which defers (or blocks) to the Scheduler to unblock other Tasks or run the idle Task which is the Arduino loop() function.
The loop() function can then put the CPU to sleep, reducing power consumption. See the feilipu.me post on topic for more.
vTaskDelay() counts Ticks, so hence the need to divide by the Tick period in milliseconds. i.e.
Time in ms / portTICK_PERIOD_MS = Ticks
#include <Arduino_FreeRTOS.h>
#include <croutine.h>
#include <event_groups.h>
#include <FreeRTOSConfig.h>
#include <FreeRTOSVariant.h>
#include <list.h>
#include <mpu_wrappers.h>
#include <portable.h>
#include <portmacro.h>
#include <projdefs.h>
#include <queue.h>
#include <semphr.h>
#include <Stack_Macros.h>
#include <task.h>
#include <timers.h>
void setup()
{
}
void loop()
{
}
Found the issue, the includes where in the wrong order: dont know why;).
You cant only include freeRTOS in MS VS you need to correct the order of the includes by yourself.
Here is the correct order:
#include <Arduino_FreeRTOS.h>
#include <croutine.h>
#include <event_groups.h>
#include <FreeRTOSConfig.h>
#include <FreeRTOSVariant.h>
#include <list.h>
#include <mpu_wrappers.h>
#include <portable.h>
#include <portmacro.h>
#include <projdefs.h>
#include <queue.h>
#include <semphr.h>
#include <StackMacros.h>
#include <task.h>
#include <timers.h>
I'm not sure about the Arduino code you are referring to, but normally there is no reason to include FreeRTOSConfig.h directly - instead include FreeRTOS.h first, and that will get the ordering of the port layer files and FreeRTOSConfig.h files correct for you, then include the header files that contain the API functions you want to use.
When I'm trying to build what seems to be any code in the Arduino IDE, it fails with this error:
Arduino: 1.6.5 (Mac OS X), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/USBCore.cpp:19:19: fatal error: Reset.h: No such file or directory
#include "Reset.h"
^
compilation terminated.
Error compiling.
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
The code I'm trying to build is from https://www.arduino.cc/en/Tutorial/Fade:
/*
Fade
This example shows how to fade an LED on pin 9
using the analogWrite() function.
The analogWrite() function uses PWM, so if
you want to change the pin you're using, be
sure to use another PWM capable pin. On most
Arduino, the PWM pins are identified with
a "~" sign, like ~3, ~5, ~6, ~9, ~10 and ~11.
This example code is in the public domain.
*/
int led = 9; // the PWM pin the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
// the setup routine runs once when you press reset:
void setup() {
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// set the brightness of pin 9:
analogWrite(led, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
Why is this happening? I don't think I've changed any of the Arduino libraries, but wondering if that's the case now. A find in /Applications/Arduino.app/ lists no files called Reset.h, however, I did find a ~/Library/Arduino15/packages/arduino/hardware/sam/1.6.4/cores/arduino/Reset.h.
Building with Arduino IDE 1.6.5, using a Mega 2560 and /dev/cu.usbmodem1421.
It turns out my Android installation was modified, and the modified USBCore.cpp wasn't really correct for this version (1.6.5) of Arduino. Reinstalling fixed the problem.