arduino

Android USB API: Switch between charge and data send

醉酒当歌 提交于 2019-12-22 04:43:20
问题 I'm starting to use the Android USB API to send data from an Arduino to an Android device. Is it possible to programmatically switch between send/receive data and just charge the Android phone? I know that you cannot do both things at the same time, and, since you have to open a FileInputStream in order to be able to receive data, as long as this is open the device won't be charged. Will it be just as simple as closing this stream to charge again? If is as simple as it, can the Arduino then

correct way to include .cpp and .h files in an Arduino sketch

*爱你&永不变心* 提交于 2019-12-22 02:04:07
问题 First, the problem: main sketch file: char foo; // required to clean up some other problems #include <Arduino.h> // tried it in desperation, no help #include "a.h" void setup(){ Serial.begin(9600); Serial.println("\nTest begins"); for (int num = -1; num < 1; num++){ Serial.print(num); if (isNegative(num)){ Serial.println(" is negative"); } else { Serial.println(" is NOT negative"); } } } void loop(){} // a.h #ifndef H_A #define H_A boolean isNegative(int x); // Err#1 int anotherOdity();

Inheritance in Arduino Code

一曲冷凌霜 提交于 2019-12-22 01:31:49
问题 I'm writing some Arduino code and attempting to use inheritance in some classes. I have a class "Actor" (my base class) and a class "Marble" (which inherits from Actor). Here are the header files: Actor.h: #ifndef Actor_h #define Actor_h #include "Arduino.h" class Actor { public: Actor(); void speak(); private: }; #endif Marble.h: #ifndef Marble_h #define Marble_h #include "Arduino.h" #include "Actor.h" class Marble : public Actor { public: Marble(); virtual void speak(); private: }; #endif

Android and Arduino both receiving strange values via Bluetooth

寵の児 提交于 2019-12-21 22:32:19
问题 I am using BluetoothChat code on the Android side to send an ON/OFF signal (I am sending 110, 119 or other cases as defined below) to the Arduino UNO using the chat box, but when I display the received value, it shows strange values in the Arduino Serial monitor, that is, 255, 254, 250 or 245 and replies with strange values on the Android side too. but suprisingly only single condition among 110, 119, etc gets true when i send these commands from android and no other instruction/LED gets

POST request on arduino with ESP8266 using WifiESP library

孤街醉人 提交于 2019-12-21 21:44:27
问题 I am attempting to make RESTful POST request using the WifiESP library (https://github.com/bportaluri/WiFiEsp). I'm able to successfully make the request with curl, but consistently get an error using the Arduino and ESP. I suspect the problem is related to the manual formatting of the POST request the library requires, but I don't see anything wrong. Here my sanitized code: if (client.connect(server, 80)) { Serial.println("Connected to server"); // Make a HTTP request String content = "{

macOS X Mojave 10.14 Beta FTDI USB Serial Driver

纵饮孤独 提交于 2019-12-21 20:23:08
问题 I just installed macOS Mojave 10.14 Beta and when i connect an Arduino to the USB port, nothing appears in my Arduino IDE ports list. if i try ls /dev/tty.* i just see /dev/tty.Bluetooth-Incoming-Port connected. On macOS 10.13 everything was working ok. I tried reinstalling the driver ( http://www.ftdichip.com/Drivers/VCP/MacOSX/FTDIUSBSerialDriver_v2_4_2.dmg ) many times, I also tried following https://learn.sparkfun.com/tutorials/how-to-install-ftdi-drivers/mac but the port never appear.

Arduino doesn't get recognized

南楼画角 提交于 2019-12-21 17:22:50
问题 I'm not certain this is the right place to ask, but I've seen other Arduino threads on stackoverflow, so I just assume it's ok. My arduino uno-compatible board is not getting recognized. I tried it on windows 8 and on windows xp. When I open the device managers, there is just one entry called 'USB serial port' under the 'Ports (COM & LPT)' section. The Arduino, however, does blink when connected. I tried uninstalling the usb serial port drivers, or updating them, but both don't work: the

How to match text in string in Arduino

风格不统一 提交于 2019-12-21 09:39:09
问题 I have some issues with Arduino about how to match text. I have: String tmp = +CLIP: "+37011111111",145,"",,"",0 And I am trying to match: if (tmp.startsWith("+CLIP:")) { mySerial.println("ATH0"); } But this is not working, and I have no idea why. I tried substring , but the result is the same. I don't know how to use it or nothing happens. Where is the error? 回答1: bool Contains(String s, String search) { int max = s.length() - search.length(); for (int i = 0; i <= max; i++) { if (s.substring

Is the C++ Standard Library fully supported on Arduino?

拟墨画扇 提交于 2019-12-21 09:33:44
问题 Not asking about <string> but about the Standard-Library as a whole for use on micro-controllers. I don't yet own an Arduino board to execute code on, and as the title says, I'm curious if the C++ Standard-Library is fully supported on Arduino and already part of the Arduino IDE. It really goes without saying that the Standard-Library is probably the most efficient, fully tested, and resource-minimal publicly available C++ code out there, and would make life much easier to code for micro

Unable to sync computer time to Arduino via USB

白昼怎懂夜的黑 提交于 2019-12-21 09:23:20
问题 I want to sync the Time from my pc to the arduino. I am using their Time library but it does not work. How can I get the arduino to have the same time as on my computer ? I am currently using a mac. Their documentations says : On a unix system, you can set the time with the shell command: TZ_adjust=-8; echo T$(($(date +%s)+6060$TZ_adjust)) > /dev/tty.usbserial-A8008pym I tried on the terminal >export TZ_adjust=-8; echo T$(($(date +%s)+6060$TZ_adjust)) > /dev/tty.usbmodemfd131 and I get