arduino

What is the difference between Serial and Stream on the Arduino, and how is Serial.write implemented?

我怕爱的太早我们不能终老 提交于 2019-12-11 04:24:05
问题 I'm having a lot of trouble understanding the difference between the terms Serial and Stream. Is Serial not a type of Stream? I have questions on homework that I just don't understand. Computers "read" the data they send each other by using (Streams or Serial?) to determine what each byte means? Also, Serial.write() confuses me a lot too. It returns a byte of data, correct? A byte is 8 bits. So if an int type (16-bits) is passed to Serial.write() on the Arduino, it would return 2 bytes to the

How to form String Using pixel Array and read all characters value of array

谁说胖子不能爱 提交于 2019-12-11 04:18:12
问题 I am Creating a binary image from processing ide. i want to use pixel array as a string . when i convert this pixel array to string i can't read String characters. every time i get an error. array index of bound. please help to out of this problem for(int y = 0; y < img.height; y++) { for(int x=0; x < img.width; x++) { int i = x+y*img.width; String s = str(i); int c = s.charAt(1); print(c); } } when i run this code in processing software i get an error in console that String Index out of

Adobe Flash app to read from SOCAT instance on Raspberry Pi?

人盡茶涼 提交于 2019-12-11 04:16:06
问题 I am not clear where my trouble is stemming as I believe all things are set up properly, yet my Flash app STILL can not make a connection to 'SOCAT' to read the incomigng serial data from a connected Arduino. Project Summary: Adobe Flash app Written in ActionScript 2 (AS2.0) This does have a camera object in it, (but that seems to be working just fine, and is not a focal point here) RPi 3B Rev.2 LAMP installed (Apache, MySQL, PHP and MyPHPAdmin as well) Running a SOCAT instance upon boot,

Sending ASCII from C# to Arduino using Bluetooth

不打扰是莪最后的温柔 提交于 2019-12-11 03:51:56
问题 I am trying to interface my C# Windows Forms application from my laptop to the Arduino Duemilanove. A Bluetooth module is connected to the Tx and Rx pins on the Arduino. My goal is to light up the on-board LED when I type in the letter 'a' and so far it has been unsuccessful. I am sure the Bluetooth is connected with my laptop, but it is not responding to the letter I am pressing. C# code public partial class Form1 : Form { private Guid service = BluetoothService.SerialPort; private

initializing array of variable size inside a class

可紊 提交于 2019-12-11 03:46:33
问题 I am trying to initialize an array of size n based off the input argument of my constructor. This works: //Inside Header class runningAverage{ private: byte n; float array[10]; public: runningAverage(byte); }; //Inside .cpp runningAverage::runningAverage(byte a){ n = a; for (byte i = 0; i<n; i++) { array[i] = 0; } } and this does not work: //Inside Header class runningAverage{ private: byte n; float array[]; public: runningAverage(byte); }; //Inside .cpp runningAverage::runningAverage(byte a)

Arduino CLI Compiler “ino” and some basic sketches lead to compile errors

安稳与你 提交于 2019-12-11 03:30:02
问题 I am trying to compile a basic Ethernet/UDP-Sketch with the cli compiler ino. I have the newest version downloaded from their github repo. ino init and then the content of src/sketch.ino: #include <SPI.h> // needed for Arduino versions later than 0018 #include <Ethernet.h> #include <EthernetUdp.h> // UDP library from: bjoern@cs.stanford.edu 12/30/2008 // Enter a MAC address and IP address for your controller below. // The IP address will be dependent on your local network: byte mac[] = { 0xDE

USB Communication from Arduino to Unity: Timeout Error

一笑奈何 提交于 2019-12-11 03:03:28
问题 I'm trying to set up the simplest possible USB communication between an Arduino and Unity 3D: sending a few bytes from the Arduino and then reading them from Unity. I'm using an older MBP, Unity 4.6.6, and an Arduino Uno with Arduino 1.0.6. Arduino: void setup() { Serial.begin(9600); } void loop() { int val=45; Serial.write(val); delay(10); } Unity: using UnityEngine; using System.Collections; using System.IO.Ports; public class ardCom : MonoBehaviour { SerialPort stream = new SerialPort("

Arduino Arithmetic error negative result

此生再无相见时 提交于 2019-12-11 02:56:16
问题 I am trying to times 52 by 1000 and i am getting a negative result int getNewSum = 52 * 1000; but the following code is ouputting a negative result: -13536 回答1: An explanation of how two's complement representation works is probably better given on Wikipedia and other places than here. What I'll do here is to take you through the workings of your exact example. The int type on your Arduino is represented using sixteen bits, in a two's complement representation (bear in mind that other

How can I create interrupts in C for Arduino?

天大地大妈咪最大 提交于 2019-12-11 02:52:28
问题 So I did this code for Arduino in C. It is for controlling a stepper motor. But every time I have to wait until the microcontroller begins a new loop so that it can take the value for the new variables, how can I create an interrupt so it will do it in any time of the program? #include <avr/io.h> #define F_CPU 4000000UL #include <util/delay.h> #include "IO/ioconfig.h" #include "leebotones/leebotonesA.h" #include "leebotones/leebotonesB.h" #include "rutina/avanza.h" #include "rutina/retrocede

How can I prevent the need to copy strings passed to a avr-gcc C++ constructor?

偶尔善良 提交于 2019-12-11 02:33:44
问题 In the ArduinoUnit unit testing library I have provided a mechanism for giving a TestSuite a name. A user of the library can write the following: TestSuite suite("my test suite"); // ... suite.run(); // Suite name is used here This is the expected usage - the name of the TestSuite is a string literal. However to prevent hard-to-find bugs I feel obliged to cater for different usages, for example: char* name = (char*) malloc(14); strcpy(name, "my test suite"); TestSuite suite(name); free(name);