arduino

Stuck in while loop arduino

。_饼干妹妹 提交于 2020-01-16 14:49:51
问题 Here is my while main loop void loop () { s4state = digitalRead(11); //Lit pin 11 switch if (s4state == 1) { // wargning/detrese detresse(1); } if (s4state == 0) { // wargning/detrese detresse(0); } } And here is the function I want to call. void detresse(int valeurPin) { while(1==valeurPin) { digitalWrite (2, HIGH) ; digitalWrite (3, HIGH) ; digitalWrite (4, HIGH) ; digitalWrite (5, HIGH) ; digitalWrite (6, HIGH) ; digitalWrite (7, HIGH) ; delay (500) ; digitalWrite (2, LOW) ; digitalWrite

Struct received over COM port from Arduino has incorrect values in some but not all of its fields

我怕爱的太早我们不能终老 提交于 2020-01-16 11:27:28
问题 I want to send some serial values to my PC. Arduino with sensors (master) >> via Bluetooth >> Arduino (slave) >> via serial com port >> PC with C# app Serial transmission works well from master to slave, but how can I receive and convert the values received to floats on the PC side using C#? Slave code is: Struct definition typedef struct { char bt1; float bt2; float bt3; float bt4; float bt5; float bt6; float bt7; char bt8; } PayloadBT; PayloadBT payloadBT; Struct sent to pc BT_writeAnything

safe and fast method for communicating a mix list of integers and booleans between pyserial and Arduino

北慕城南 提交于 2020-01-16 09:05:14
问题 I want to send and receive a mix list of integers and booleans between pyserial and an Arduino. I have figured the Arduino to pyserial out, well partly: Arduino code: ... bool var1 = ...; int var2 = ...; ... void setup() { ... Serial.begin(9600); ... } void loop() { ... // here I send the data in CSV format Serial.print(var1); Serial.print(", "); Serial.print(var2); Serial.print(", "); ... Serial.println(var_n); ... } and the pyserial side: import serial serPort = serial.Serial("COM7")

Serial communication between pc and Arduino through USB

浪尽此生 提交于 2020-01-16 08:42:01
问题 I have some C++ code that I need to use for serial communication between PC and Arduino. The file "Serial.cpp" is including a file called "stdafx.h" that doesn't exist in the project or anywhere on my computer, which obviously causes an error. Other than that, I also get other errors, such as C2065 'CSerial': undeclared identifier . Here are the three files that are in the project: Serial.h #ifndef __SERIAL_H__ #define __SERIAL_H__ #pragma once #include <Windows.h> #include <memory.h> #define

Serial communication between pc and Arduino through USB

自作多情 提交于 2020-01-16 08:40:11
问题 I have some C++ code that I need to use for serial communication between PC and Arduino. The file "Serial.cpp" is including a file called "stdafx.h" that doesn't exist in the project or anywhere on my computer, which obviously causes an error. Other than that, I also get other errors, such as C2065 'CSerial': undeclared identifier . Here are the three files that are in the project: Serial.h #ifndef __SERIAL_H__ #define __SERIAL_H__ #pragma once #include <Windows.h> #include <memory.h> #define

Problems with connecting HC-05 Bluetooth module to PC

一曲冷凌霜 提交于 2020-01-16 08:35:42
问题 So i've been trying to connect my HC-05 BT module to PC. I'm sure i connected everything correct, i'm not new with arduino stuff. What i try to do now is i want to communicate with arduino using uart connection via BT. I have arduino leonardo, and here is my code: void setup() { Serial1.begin(9600); pinMode(LED_BUILTIN, OUTPUT); } void loop() { if (Serial1.available()>0) { String ainfo; ainfo = Serial1.readStringUntil('\n'); if (ainfo.equals("ON")) { digitalWrite(LED_BUILTIN, HIGH); Serial1

Java rxtx code to connect to rfcomm0 is not working

纵饮孤独 提交于 2020-01-16 01:54:25
问题 I have successfully connected my arduino uno R3 with bluetooth mate module and am able to send data to my laptop running Ubuntu 12.04 via bluetooth. (using serial port protocol). The data is received on rfcomm0. The following code displays the received data : sudo screen /dev/rfcomm0 Now I am facing problems in reading this data in a java program. I have referred the code from http://playground.arduino.cc/Interfacing/Java. This uses the rxtx library to access the serial port. Here is the code

Arduino初级教程

淺唱寂寞╮ 提交于 2020-01-16 00:26:29
目录 1. Arduino概述 2.Arduino板 3.Arduino安装 4.Arduino程序结构 5.Arduino数据类型 6.Arduino变量 7.Arduino运算符 8.Arduino控制语句 9.Arduino循环 10.Arduino函数 11.Arduino字符串及字符串对象 12.Arduino时间函数 13.Arduino数组 14.Arduino函数库 (1)Arduino I/O函数 (2)Arduino字符函数 (3)Arduino数学库 (4)Arduino三角函数 1. Arduino概述 Arduino是一个基于易用硬件和软件的原型平台。由可编程电路板和Arduino IDE的软件组成,将计算机代码写入并上传到物理板。 特点: 板卡读取来自传感器的模拟或者数字输入信号,转换为输出。 通过IDE向板上的微控制器发送一组指令控制板功能。 使用USB线将代码加载到电路板上。 2.Arduino板 板名称 工作电压 时钟速度 数字I/O 模拟输入 PWM UART 编程接口 Arduino UNO R3 5V 16MHZ 14 6 6 1 USB通过ATMega16U2 使用板如下: 组成部件 电源USB:板卡使用PC机的USB线供电。 电源(桶插座):板卡可以直接从交流电源供电。 稳压器:控制提供给板卡的电压,稳定处理器和其他元件的直流电压。

Arduino - Optimising existing method for iterating through an array

本小妞迷上赌 提交于 2020-01-15 11:24:00
问题 Is there a more efficient and cleaner way of doing what the following method is already doing? void sendCode(prog_uint16_t inArray[], int nLimit) { unsigned int arr[nLimit]; unsigned int c; int index = 0; while ((c = pgm_read_word(inArray++))) { arr[index] = c; index++; } for (int i = 0; i < nLimit; i=i+2) { delayMicroseconds(arr[i]); pulseIR(arr[i+1]); } } This is in reference to an existing question I had answered. Arduino - Iterate through C array efficiently 回答1: There should be no need

Arduino - Optimising existing method for iterating through an array

帅比萌擦擦* 提交于 2020-01-15 11:23:06
问题 Is there a more efficient and cleaner way of doing what the following method is already doing? void sendCode(prog_uint16_t inArray[], int nLimit) { unsigned int arr[nLimit]; unsigned int c; int index = 0; while ((c = pgm_read_word(inArray++))) { arr[index] = c; index++; } for (int i = 0; i < nLimit; i=i+2) { delayMicroseconds(arr[i]); pulseIR(arr[i+1]); } } This is in reference to an existing question I had answered. Arduino - Iterate through C array efficiently 回答1: There should be no need