arduino

Arduino: printf/fprintf prints question mark instead of float

 ̄綄美尐妖づ 提交于 2019-12-17 16:47:31
问题 I have the following code for an Arduino sketch: #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); static FILE lcdout = {0} ; static int lcd_putchar(char ch, FILE* stream) { lcd.write(ch) ; return (0) ; } void setup() { lcd.begin(16, 2); fdev_setup_stream (&lcdout, lcd_putchar, NULL, _FDEV_SETUP_WRITE); } void loop() { stdout = &lcdout; printf("%.2f Volts", 2.0); } The problem comes at the last line of the code. This should print out "2.00 Volts" but instead, it prints "?

Apploader - upload Arduino sketches over BLE from iPad/iPhone - Start guide

易管家 提交于 2019-12-17 10:41:35
Basics Hardware Before we start check you have the following: 1. Arduino Uno , Arduino Mega 2560 or Arduino Nano board 2. HM-10 , HM-11(both preferred) or HC-8 BLE module First, set baud rate 115200 for your BLE module using AT-command for Uno or Mega2560 or 57600 for Nano board. For HM-10 you can use AT+BAUD? command to check current baud rate and AT+BAUD4 to set baud rate 115200 or AT+BAUD3 to set baud rate 57600. Consult HM-10 datasheet if necessary. You can use mega-to-hm10 sketch to use Mega as USB-to-TTL converter to send AT-commands: Second, wire the schematic: Arduino HM-10 pin 0 (RX

Serial communication between Arduino and Matlab is losing data

三世轮回 提交于 2019-12-17 07:55:20
问题 I am now trying to establish the serial communication between Arduino and Matlab. The script is very simple: Matlab send a number named as i to Arduino; Arduino receive this i , then send it back to Matlab; Repeat step 1&2 for 10 times, i.e., Matlab sends 1,2,...,10 to Arduino, then receive the 1,2,...,10 from Arduino. However, Matlab only get back 3,4,...,10, while the first i=1 and i=2 are lost (I have already made the inputbuffersize=200 now, still not right). Hereby is the code from

Convert serial.read() into a useable string using Arduino?

穿精又带淫゛_ 提交于 2019-12-17 06:59:05
问题 I'm using two Arduinos to sent plain text strings to each other using newsoftserial and an RF transceiver. Each string is perhaps 20-30 characters in length. How do I convert Serial.read() into a string so I can do if x == "testing statements" , etc.? 回答1: From Help with Serial.Read() getting string : char inData[20]; // Allocate some space for the string char inChar=-1; // Where to store the character read byte index = 0; // Index into array; where to store the character void setup() {

Mapping a numeric range onto another

痞子三分冷 提交于 2019-12-17 05:36:52
问题 Math was never my strong suit in school :( int input_start = 0; // The lowest number of the range input. int input_end = 254; // The lowest number of the range input. int output_start = 500; // The lowest number of the range output. int output_end = 5500; // The largest number of the range ouput. int input = 127; // Input value. int output = 0; How can I convert the input value to the corresponding output value of that range? For example, an input value of "0" would equal an output value of

Vectors in Arduino

可紊 提交于 2019-12-17 04:59:40
问题 I am making a vector of "waypoints" on the Arduino. Each waypoint is an object. The Arduino will obviously need to store multiple waypoints for waypoint navigation. But instead of storing these waypoints in a standard preprogrammed array, the user will need to be able to add, remove waypoints and move them around. Unfortunately the Arduino does not offer a vector type as a built-in library. I am currently contemplating two options: In Container for objects like C++ 'vector'? , someone posted

Vectors in Arduino

◇◆丶佛笑我妖孽 提交于 2019-12-17 04:57:08
问题 I am making a vector of "waypoints" on the Arduino. Each waypoint is an object. The Arduino will obviously need to store multiple waypoints for waypoint navigation. But instead of storing these waypoints in a standard preprogrammed array, the user will need to be able to add, remove waypoints and move them around. Unfortunately the Arduino does not offer a vector type as a built-in library. I am currently contemplating two options: In Container for objects like C++ 'vector'? , someone posted

Store value in variable after HTTPREAD

放肆的年华 提交于 2019-12-17 03:44:33
问题 I am working with a GSM SIM900 and an Arduino Uno. I am using AT commands for the SIM900. I am successfully getting data from GET requests and showing on the serial monitor, but after the AT+HTTPREAD command I want to store data into a variable. How can I do this? I am getting a JSON Object from the web server and I want to get the Status property from that object and save it into a variable. #include <SoftwareSerial.h> SoftwareSerial gprsSerial(2,3); void setup() { gprsSerial.begin(9600);

arduino学习笔记十九--水位报警器

ぃ、小莉子 提交于 2019-12-15 06:46:13
介绍 水位报警器,当水接触到2个金属头时候,触发报警。 清单 无源蜂鸣器一个 一个LED 一个470欧姆电阻 一个10K电阻 9根杜邦线 实验板一片 一个水杯(自备) 原理图 1 接线,按照原理图接线 2准备一个被子,一瓶水做试验 3下载程序到 ARDUINO开发板 4 固定下2个 检测触点。 5 慢慢倒水,当水同时接触到水时候,触发报警。 代码: void setup() { pinMode(A5,OUTPUT); //让模拟口A5作为数字口输出 pinMode(A0, INPUT); } void loop() { int n=analogRead(A0); if (n>=100) { digitalWrite(A5, HIGH); pinMode(A2,OUTPUT); //蜂鸣器频响 0.5秒 tone(A2,800); delay(500); pinMode(A2,INPUT); digitalWrite(A5, LOW); delay(500); } } 来源: CSDN 作者: 甜航一直在 链接: https://blog.csdn.net/qq_37631068/article/details/103447615

arduino学习笔记二十--无源蜂鸣器+ARDUINO开发板播放音乐

Deadly 提交于 2019-12-15 05:37:08
无源蜂鸣器+ARDUINO开发板播放音乐 用到材料 1个无源蜂鸣器 2根杜邦线 一片开发板 原理图 蜂鸣器长脚的为正,短脚为负极。 在蜂鸣器的底下也有标价正负。 接好线,选择喜欢的程序 1超级玛丽 扬声器 2蜂鸣器唱歌 小星星 国际歌 3模拟防控警报的响声 提供 3个测试程序,自己选择自己喜欢的下载玩玩。 代码: 超级玛丽 /* Play Super Mario theme song with Arduino and speaker circuit: * 8-ohm speaker on digital pin 8 created 4 June 2011 by naozhendang.com reference: http://arduino.cc/en/Tutorial/Tone */ #define NOTE_B0 31 #define NOTE_C1 33 #define NOTE_CS1 35 #define NOTE_D1 37 #define NOTE_DS1 39 #define NOTE_E1 41 #define NOTE_F1 44 #define NOTE_FS1 46 #define NOTE_G1 49 #define NOTE_GS1 52 #define NOTE_A1 55 #define NOTE_AS1 58 #define NOTE_B1 62