Take a look at boost asio or Qt Serial Port. Both are portable versions for serial-communication with C++. There is no other option, which could be simpler than serial communication....
this basically increments through the available options on a standard US telephone keypad for the "3" key, looping back to the first option after the last is reached. it does so by referencing a 3-dimensional array containing the options for each key layed out as row/column/options. it is written in...
controller,arduino,hardware,sensor,temperature
You need to connect the 18B20 to a microcontroller, or a 1-wire host controller, connected to the microcontroller. (The difference is whether you want to write your own 1-wire protocol code ... go with the host controller). You'll get a digital value for the temp, no ADC required.
binary,arduino,arduino-uno,eeprom
you are sending binary numbers to the serial port and not converting them to ascii, do this small change in your setup code by converting the binary numbers to ascii, char my_buffer_ax[10]; char my_buffer[200]; memset(my_buffer, 0, 200); strcat(my_buffer, "PO: "); //Set address pins to output for (int i=0; i <...
if(year(t)==1970) { getTime(); } year() returns 4-digit year integer. not a string....
c,matrix,arduino,calculator,linear-algebra
It's a floating point error, the final value you are getting is very close to zero. Demo. Add a small epsilon value to your final test to allow for floating point inaccuracies: if(fabs(a[cant-1][cant-1]) < 0.000001){ lcd.print("No solucion"); /* if there is no solution print this*/ ...
python,arduino,pyserial,serial-communication
its not hard here is a simple example, its usually a good idea to start simple and then increase the functionality to what you want. test_serial.py import serial ser = serial.Serial("COM4",timeout=5) # everything else is default ser.write("\x45") print "RECIEVED BACK:",repr(ser.read(5000)) test_serial.ino int incomingByte = 0; // for incoming serial data...
Is avrdude in the path? If it is not you can call the setWorkingDirectory before executing the process or add it to the path. In order to check it, open the command line, cd into the binary folder of your Qt application and enter the command: avrdude -Cavrdude.conf.txt -v -v...
Most of your attempts have the same issue, you have stored the pointer to the table in progmem but the actual table data itself (in this case the strings) are not stored in progmem. Unfortunately GCC attributes (as of gcc 4.7) only apply to the current declaration so you have...
No reason you can't have two separate radios on a single device. Just be sure to configure them with different 802.15.4 channels to avoid interference. Your Arduino Mega can access both networks and can choose to handle data in whatever way you please.
lcd is a pointer lcd.init(); lcd.clear(); lcd.print("Constructor"); Above lines should correct as follows: lcd->init(); lcd->clear(); lcd->print("Constructor"); ...
First, in setup: pinMode(buttonPin , INPUT); Second, what are you expected when setting==3? You aren't reloading/updating the variables for brightR brightG brightB. So, when you change setting, you will lost the change of brightness...
sure, why not, it is just spi. I think just out of convenience (of something with spi on it or trivial to bit bang) I use another microcontroller to program my avr (an msp430 or mbed which program easily over usb). avrs docs are pretty good on the protocol. you...
c++,node.js,serial-port,arduino,intel-edison
It appears 115200 is an unusable baud for the Edison serial to Arduino block! I set the baud to 9600 and have successfully gotten the expected data. Additionally, the gpio pins for the Arduino block is 130 and 131. (130==rx, 131==tx) echo -n 130 > /sys/class/gpio/export //may not need, may...
You could try using a state variable. Declare a boolean variable such as: boolean runSequence = false; Now, when you detect a button press, just toggle the state: // Replace this condition to whatever matches your button setup if ( digitalRead(pin) == HIGH ) { runSequence = !runSequence; } Then,...
well this was funny but after realizing its about serial port i tried few things and the reason for me to wait serial port is : while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only } i didnt care what for this used and...
So following @PaulOgilvie's idea I fixed the problem with the following code: if (BPY >= 160 || BPY <= 0) {//Goal Detection if (BPY >= 160) { playerScore = playerScore + 1; } else { computerScore = computerScore + 1; } DrawCourt(0); EsploraTFT.fillCircle(BPX, BPY, 7, ST7735_BLACK); EsploraTFT.fillRect(computerPaddle, 154, 32, 3,...
c,arduino,data-type-conversion
Convert the String into a char array first: size_t len = myString.length(); char buf[len+1]; // +1 for the trailing zero terminator myString.toCharArray(buf, len); and then you can pass buf: bool ok = network.write(header,buf,strlen(buf)); ...
I finally found my mistake: when I do: Wire.write(0); I forgot to start the transmission with: Wire.beginTransmission(device);
You have to tell Arduino that your library uses C naming. You can use extern "C" directly in the Arduino code. The next code compiles in Arduino IDE 1.05. extern "C"{ #include <mycLib.h> } void setup() { mycLibInit(0); } void loop() { } mycLib.h #ifndef _MY_C_LIB_h #define _MY_C_LIB_h typedef struct...
c,arduino,embedded,processing,atmega
Yes It will take processing time even if no serial monitor or other device is connected. A good practice is to a have a #define pre-processor directive in your code indicating whether you are debugging or not. e.g. #define DEBUG_PHASE #ifdef DEBUG_PHASE printf(...); #endif ...
You can access the data as if you were accessing an array. To test this you can (temporarily) comment out your FLASH-writing piece of code and run this snippet: byte *p = (byte*)ADDRESS_OF_PAGE(MY_FLASH_PAGE); Serial.println("The data stored in flash page " str(MY_FLASH_PAGE) " contains: "); for (count = 0; count <...
arduino,avr,atmega,avrdude,atmelstudio
Provided you are familiar with C, I recommend to start with the AVR Libc reference inspect iom328p.h for your processor specific definitions (located under ...\Atmel Toolchain\AVR8 GCC\Native\[#.#.####]\avr8-gnu-toolchain\avr\include\avr) optionally, in Atmel Studio create a new ASF board project selecting device ATmega328p and inspect the sources loaded into your project folder from...
Others have tried to answer the question - but I think the basic confusion is not resolved line[:-5] will remove last 5 characters from a line For example if your line is 'abcdefghijklm' then line[:-5] would give 'abcdefgh'. Now let's look at your adruino code specifically following line Serial.print(id_lum) Now...
Several problems there. Let's start with the compilation errors: You have two functions turnLeft and two functions moveForward. I assume the second pair should be turnRight and moveBackwards. In the moveForward function you call servoRight(0) this should probably be servoRight.write(0). Fixing this should allow your code to compile, but it...
The inverse FFT can be obtained by making use of the forward transform: for (int i = 0 ; i < 512 ; i += 2) { fft_input[i] = (fft_input[i] >> 8); fft_input[i+1] = -(fft_input[i+1] >> 8); } fft_reorder(); fft_run(); // For complex data, you would then need to negate...
You are misunderstanding how servos work. First off, they have to have a high pulse from ~700~2300us. A high pulse that is 1500us long will center the servo. Using a delay in ms will NOT work. You must use delayMicroseconds. Additionally, even the slightest time jitter in the pulse will...
c++,arrays,dynamic,struct,arduino
NO the previously allocated memory will not be freed. You will lose all allocated memory. By overwriting your persons pointer, you lose your handle on the allocated storage. So before you do this, you have to call ::operator delete(persons[0].pets); ::operator delete(persons[1].pets); ::operator delete(persons); This is pretty ugly, isn't it? For...
You should look at Freescale's app note AN4481, which is referred to by the datasheet. Page 5 shows the single-byte read operation which is what you are doing, except that the register address write must not be followed by a STOP but instead uses a REPEATED-START. I'm not familiar with...
It wasnt a sytax error .. Had to add board.servoConfig(5, 0, 30); I added it in the code like this: var firmata = require('firmata'); var board = new firmata.Board('COM4',function(){ }); var WebSocketServer = require('ws').Server; var wss = new WebSocketServer({ port: 8081 }); wss.on('connection', function connection(websocket) { websocket.on('message', function incoming(message) {...
Technically, the first syntax creates a temporary object and uses that to copy construct the matrix object. The second syntax avoids the extra copy and constructs matrix directly. So your simplified syntax is better. However, a compiler would likely optimize the difference away, so that the resultant object code would...
My suggestion to you would be to add a delay to your code after the Serial.print("Storage");, like so: buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { Serial.print("\t"); Serial.println("Storage"); delay(500); } } What I suspect is happening is that even when you push the button quickly, the void loop goes through...
with android lP version, android checks the network internet status and if connected network do not have internet and in previous connected network(any of) have internet ,Android device gives preference to internet enable network.
c,arduino,microcontroller,ftdi,intel-edison
May be when they tested the sample code, they used a chip whose ID was 10108 but on the actual board they are using the different chip. The guys said rightfully..You need to comment out that line to reject any chip ID checking mechanisms. Moreover you can also edit the...
post,networking,get,arduino,nfc
You can't do it directly, but if you're planning to use USB, you can send data using the various serial commands to the PC you're connected to. You'll need a program written in your language of choice on the PC listening to the arduino and that program can submit...
I have tried to simplify our code and fix your problem I can't test it, so I can't be sure everything is good I use byte instead of int for memory footprint consideration I have removed time and directly deal with the bullet position To be easier to understand I...
It is because you declare buffer on the stack. If you want to return a dynamically allocated buffer, use malloc: uint8_t *buffer = new uint8_t[length]; if (buffer == NULL) error_allocation; // Make sure to de-allocate after you finish to use it delete [] buffer; ...
java,serial-port,arduino,gnu,rxtx
I have not found any solution for closing serial port of rxtx package in windows 8.1 environment, I moved therefore to JSSC package and it works much better, the full solution including closing port and event listener can be found here. JSSC solution...
testing,arduino,software-design,fingerprint,biometrics
The short answer is yes. The long answer is you will need a lot of things to do so. The first is you will need to find out which fingerprint scanner you have in your laptop. Then you will need to find out what SDK's that device manufacturer offers. Most...
string,serial-port,arduino,hex,rfid
byte MF_GET_SNR[8] = {0xAA, 0x00, 0x03, 0x25, 0x26, 0x00, 0x00, 0xBB}; /* This will contain the RFID receiver response (11 is taken from your example) */ byte RFID_DATA[11]; int RFID_DATA_index; void setup() { Serial.begin(9600); Serial1.begin(9600); } void loop() { Serial1.write(MF_GET_SNR, 8); delay(1000); RFID_DATA_index = 0; while(Serial1.available() > 0) { /*...
Basically you could do something like: int myPins[] = {2, 3, 4, 5, 6, 7, 8, 9}; byte sequence[] = {B01001001,B00000001,B00000011}; void setup(){ for(int i = 0; i < 8; i++){ pinMode(myPins[i], OUTPUT); } } void loop(){ for(int i = 0; i < 3; i++){ turnOnOff(sequence[i]); delay(500); //just to see...
Let's say you want to know what SoftwareSerial.h provides. Search for it in Arduino directory, e.g.: C:\Program Files (x86)\Arduino. All public methods are at your disposal. This applies to already installed libraries into Arduino IDE: SoftwareSerial.h: #include <inttypes.h> #include <Stream.h> ......... ......... class SoftwareSerial : public Stream { private: //...
There is a way. It is called Serial Communication. You don't communicate with the .ino file. You communicate with Arduino using the COM port which sends and receives bytes with Arduino through USB. On Unity Editor, go to Edit/Project Settings/Player and change the .Net setting to .Net 2.0 instead of...
It looks like the problem is in the delay(5000) the micro-controller will wait 5 seconds between a sample of the button's state. if you remove the delay statement it should be on and off instantly. you should try to trigger the setRemoteState only on state change, so it will not...
Yes. Code execution in a thread happens sequentially. The called function should return and the execution shall continue from the next statement in the function that called.
uint8_t oldSREG = SREG, t; is the same as: uint8_t oldSREG = SREG; uin8_t t; It just declares an object t of type uint8_t. EDIT: Question was edited, here is another answer: If your function restores SREG at its end and if your interrupt handlers are accessing SREG then oldSREG...
The receive block is a pretty low level function, so it will not be able to do such a specialized thing. State in Elixir is explicit, and can be implemented through an optional argument, the accumulator (acc in this case). You can later pass down the accumulated value to the...
I wrote a blog post about this device on an Arduino that should answer your questions. http://chrisheydrick.com/2015/02/05/adxl335-accelerometer-on-an-arduino/ In short, the values you're seeing depend on the power delivered to the ADXl335. The sensitivity (mV/g) is stated to be ratiometric in the data sheet, and the example given is that when...
It looks like you might want to redesign this. While you might want to use something like threading on a desktop platform you don't have any hardware support for concurrency in that manner on the Arduino UNO. You do however have interrupts which you can use for your current problem....
You can't have an assignment statements outside of a function/method context. Either initialize properly: unsigned char topState = 1, leftState = 1, rightState = 1, fwdState = 1, bwdState = 1; Or write/call an initialization function someplace....
Your problem is that you read your button only after led_dance is finished. You have two choices: Option one: You can make the code more cluttered and add reading state button before and after every delay like this: int buttonChanged() { // Put logic here to check button state and...
I updated my GPSLocation class as follows which solved my problem. Thanks guys. GPSLocation.h #ifndef GpsLocation_h #define GpsLocation_h #include "Arduino.h" class GpsLocation { public: float latitude; float longitude; }; #endif GPSLocation.cpp #include "Arduino.h" #include "GpsLocation.h" Setting and getting from Test.ino as follows loc1.latitude = -12.3456; Serial.print(loc1.latitude, 4); ...
There's at least two options. First, it's set up to be programmed over Bluetooth. So if you have Bluetooth on your laptop, you can connect the two wirelessly. Pins 0 and 1, per the documentation, are TTL serial transmit and receive pins (which are also used for Bluetooth communications), so...
Found the answer myself after wasting 4hours. I was better off using the readBytes() method with a byteCount of 1 and timeOut of 100ms just to be on the safe side. So now the read method looks like this. private byte read() throws SerialPortException{ byte[] temp = null; try {...
arduino,embedded-linux,arduino-ide,arduino-yun
The Yun uses Bonjour services (port 5353) for auto-discovery on a wireless network. For more information, look here.
"direction1" has not been declared anywhere in the code you pasted. Somewhere there needs to be a line of the form type direction1; for example char *direction1; or int direction1; to tell the compiler what direction1 is. The other 3 errors indicate those lines are missing semicolons at the end....
The Arduino clone device you have linked to uses the CH340 chip as its USB serial adapter. You need to obtain the drivers from the Chinese manufacturer or some other site. There are a number of blogs that provide information about using these clones (example). Provided the driver is installed...
I've posted this question on arduino.stackexchange.com and it got an answer: http://arduino.stackexchange.com/questions/11821/disturbed-digital-out-at-4mhz-on-arduino-nano/11830...
You can read here about the build process of the Arduino IDE. Before it can be compiled, your sketch needs to be transformed into a valid C++ file. Part of this transformation is to create function defitions for all your function declarations. These definitions are put in the top of...
I know nothing about NodeMCU but that is not a proper http server. For it to properly work with a browser, it should return some headers. You can try to close the connection after sending the response. Try the following: wifi.setmode(wifi.STATION) wifi.sta.config("SSID", "password") wifi.sta.connect() srv = net.createServer(net.TCP) srv:listen(80,function(conn) conn:on("receive", function(conn,...
The short answer is that if it isn't an official arduino library it falls on the shoulders of the developer to write the documentation page for that library (for example the Adafruit neo pixel) For more advance features and libraries try looking here...
You only check one message, but there are many different messages on the bus, regardless of what you send. You should either read every message until you get the one with the CAN ID you expect (probably CAN ID 0x7e8) or set an appropriate filter/mask in the MCP chip, so...
There are a few issues with your code. First you can't get the value of a variable or a define by dynamically using a string that is the name of the variable. It doesn't work that way in C. The easiest approach is to use an array and then just...
Adruino is not a programming language but a microcontroler platform for which you could write code in c. you wrote in your code: Cyi = Cyo; but Cyi is of type "bool" and Cyo a type of "bool *" correct it with Cyi = *Cyo; ...
arduino,microcontroller,arduino-uno,atmega
For Anyone with the same problem. Somebody answered my question on another Stack Exchange. It is here. Also this video may be helpful. It sure was to me. Basically you need another arduino, then you need to upload a ArduinoISD sketch(which is built in Arduino IDE) to it, and connect...
The problem is here: previousMillis = 0; previousMillis2 = 0; previousMillis3 = 0; previousMillis4 = 0; All if statement will be true on the next loop. Try with: previousMillis = micros(); previousMillis2 = micros(); previousMillis3 = micros(); previousMillis4 = micros(); ...
Arduino UNO maximum integer value is 32767 (16-bit signed integer). So both watertime and waittime are too large to store in int variables. Try slowing the timebase by using delay(1000) to control a loop that runs once every second, then express watertime and waittime using seconds instead of miliseconds. Incidentally,...
Just add the following line to reset the sketch, without the inconvenience of a board reboot: system("./opt/cln/galileo/galileo_sketch_reset_script.sh"); ...
You need a parser. A simple library that does the job is the following: http://sourceforge.net/projects/cjson/...
If you go into File->Preferences in the Arduino IDE, you can turn on Verbose Output During Compilation. This will show you exactly what is going on in the log window....
The -36 defines the maximum displacement based on font width, screen width and text length. The standard font of Adafruit_GFX is 6px per character. You need this cursor value to render the font characters correctly. Variables you need... char exampleText[32] = "This is a test"; int pixelPerChar = 6; int...
c++,serial-port,arduino,usb,raspberry-pi
The issue you are experiencing lies in the actual timeline of events. When the RPi sends the data to the Arduino, remember that it is sending it serially, i.e. one character at a time. As soon as the first byte of data arrives at the Arduino, then Serial.available() will return...
My found the issue my code was ok it was my circuit. The pins i declared to receive input was not connected to ground.
The problem is the use of += in C += doesn't concat strings. You need to concatenate the char get from Serial.read() like here for example: Convert serial.read() into a useable string using Arduino?
I made a test println() statement to print the value of c, and found that its value when BTLEserial.read() is 0000 turns out to be 48. Hardly surprising. The ASCII value of "0" is 48. The "int" that Adafruit_BLE_UART::read() returns is the most recent byte received; if you want...
arduino,arduino-uno,arduino-ide
a very simple way to achieve this is to use breakoutjs download and install, and upload the firmata sample to the arduino. You'll have to right some JavaScript code that will take care of sending requests to the distant server.
I see, that your header file, which contains declaration of init_phase_correct() is wrapped with include guard with some auto-generated name (INCFILE1_H_). Also, you did not specify, whether init_phase_correct() is declared inside PWM.h or maybe another file, that is included by PWM.h. Without more code, I cannot say for sure, but...
eclipse,arduino,make,avr,avr-gcc
The error message is coming from the assembler as. The AVR assembler avr-as does accept the -mmcu option. Perhaps Eclipse is choosing some other as instead? Using "/bin/avr-g++" in the makefile looks suspicious to me. I would think that you should set up Eclipse to look for the toolchain in...
there are many reason and you need to try 2 or 3 different operations in order to understand why avrdude is not responding First, check serial port on Arduino IDE, then check what kind of board you have selected in IDE. Have you left some connected on pin 0 or...
The problem is that pointers and post-increment does not do what you want. If you write void someFunc(int *a, int *b) { *a = *a+1; *b = *b+1; } it works See ++ on a dereferenced pointer in C? for an explanation of why *a++ increments the pointer itself....
Your XBee module is configured for escaped API mode (ATAP=2), which replaces the bytes 0x7D, 0x7E, 0x11 and 0x13 with 0x7D and the escaped character XORed with 0x20. Set ATAP=1 and you'll start seeing the expected bytes. Digi has a good Knowledge Base document explaining the escaped mode....
int counter = 0; is the beginning and if (counter <= 9999) { defines the end. Change 0 for your choice of beginning and 9999 for your choice of ending. The code works because keyboard.press and keyboard.release accepts a character to select which key to press and release. It uses...
visual-c++,serial-port,arduino
I believe that you need to terminate the string that you put into the data buffer in each loop iteration: while ((n = port->ReadData(data, 256)) != -1) { data[n] = 0; printf("%s", data); } ...
Hi all thank you very much for the help. I've ended up fixing it. See below: " The memory was okay. I think you were right that the clock speeds are different for the arduino and the attiny. I ended up using the libraries found here: https://github.com/cpldcpu/light_ws2812 Then I loaded...
In Timer.h you have: TimerAction* actions; At the point in time that the compiler sees that line of code it has not seen what a TimerAction is. As such it does not know what the type is and is giving you an error. What you need to do is forward...
c,coding-style,arduino,embedded
You should create a Hardware Abstraction Layer (HAL). The code within the HAL encapsulates all the hardware specific differences. The higher level code that calls into the HAL should not be aware of any hardware specific differences because the HAL has abstracted those details into a more generic interface. Your...
A very easy way to get the data you want is with TextFinder from the Arduino playground. I believe this should work. Note that I haven't tested it, so fingers crossed. Add this at the begining #include <TextFinder.h> #include <String.h> String result = ""; TextFinder finder( client ); Then modify...
gps,arduino,microcontroller,spi,pic32
So I am not using the SPI but UART for my Ublox LEA6T implementation. I can however speak to the fact that the NEMA you receive look valid IF there is no antenna or signal to the GPS receiver. If you post your actual SPI digitalWrite code I may be...
If you go to Project->Properties->C/C++ Build->Settings You can add a library under the appropriate compiler with -l and you can include directories for headers with -I under C/C++ General->Paths and Symbols under the includes tab.
In C++, the last character of a std::string is s.back() (UB if the string is empty, so check first.) I know that your question is tagged c, but the code itself is using std::string so I suppose it is really C++. The back() member function, which is analogous to the...
android,arduino,bluetooth-lowenergy,gatt
So, I finnally figured out my mistake :) As you can see above, I'm usinng a UUID with the same base for my descriptor as my characteristics (starting with 3f54XXXX-....) I changed it to public static final UUID X_ACCEL_DESCRIPTOR_UUID = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"); and now everything is working as expected. I did...
c++,serialization,serial-port,arduino,openframeworks
Arduino's Serial.println translates the raw bytes into their ASCII equivalent and then sends those bytes followed by linefeed (10) and carriage return (13) bytes. So, the raw byte 12 is sent as 4 total bytes -- two bytes representing the ASCII 1 (49), 2 (50) and then (10) and (13)...
As I said in a comment, the langage de prédilection for Arduino is C++, not C. So is seems a good idea to comply to the C++ way of structuring your applications. Forget the C way which often consists of workarounds for the lack of adequate mechanisms for clean programming...
data,arduino,radio,packet,eeprom
If I understand you correctly, you are attempting to read in commands from Serial, and if you encounter the 'C' command, you expect an integer value (0-512) to follow. You will need to read the integer value in. Here's one way: cmd = Serial.read(); if(cmd == 'C') { int packetNum...
Arrays in C++ don't allow this syntax. What you should do is something like this: char[2] id; if( sx1272.packet_received.length > 5 ) { id[0] = sx1272.packet_received.data[4]; id[1] = sx1272.packet_received.data[5]; } ...
c++,upload,arduino,sublimetext2
The problem is that the Arduino plugin is 1) ancient, 2) (barely) ported from a TextMate .tmBundle, and 3) only works on OS X. All of the commands rely on programs stored in /Applications/Arduino.app, which you obviously don't have on your Windows system. So, instead of using this plugin, you...
You can print the binary value of an integer using the bitwise. As far as I am concerned, I'm using this kind of function to understand how it works : int main() { int nb = 10; int i = 31; while (i >= 0) { if ((nb >> i)...
I found it ! It seems like on Raspbian, the communications were terminated by a NULL character. But not on Debian. And this NULL character was polluting my calculations of incomming buffer length. So i ended up by eventually suppress it on the Arduino side : boolean readCommand() { //...
Do you push the "RESET" button when it starts uploading? Using the pro-mini probably you haven't connected the DTR pin, so it can't auto-reset the device (so you have to do it manually). When Arduino starts the uploading phase just press the reset button. It should start....