arduino

Not able to Receive subscribed Message with PubSubClient.h in Arduino Uno R3

情到浓时终转凉″ 提交于 2020-01-15 09:28:50
问题 #include "SPI.h" #include “WiFiEsp.h” #include <WiFiEspClient.h> #include “SoftwareSerial.h” #include <PubSubClient.h> #include <WiFiEspUdp.h> float temp=0; int tempPin = 0; int isClientConnected = 0; char data[80]; char ssid[] = “SSID”; // your network SSID (name) char pass[] = “PASSWORD”; // your network password int status = WL_IDLE_STATUS; // the Wifi radio’s status char deviceName = “ArduinoClient1”; IPAddress server(xxx,xxx,xxx,xxx); //MQTT server IP IPAddress ip(192,168,43,200); void

Arduino - struct out of scope why?

孤人 提交于 2020-01-15 09:02:10
问题 I work at a motor programm (and i have to control multiple motors thats why i use the struct) together with my arduino MEGA. I dont't understand why MOTOR is out of scope when I use it as argument in the drive function: typedef struct motor { int EN; /*some more ints*/ }MOTOR; MOTOR mot1; MOTOR mot2; /*this works with no compile error*/ int drive (MOTOR*) /*here i have compile error out of scope, neither with or without pointer*/ { return 1; } void setup() {} void loop() {} sketch_jul25a:2:

Arduino + Proccesing code error “disabling_serialevent()”

本小妞迷上赌 提交于 2020-01-15 08:20:24
问题 I have some problems in my code, i can run it because i always get this error message Error, disabling serialEvent() for COM3 null import processing.serial.*; Serial port; String c = " "; String d = " "; String data = " "; PFont font; int index = 0; void setup() { size(2024, 1024); port = new Serial(this, "COM3", 9600); port.bufferUntil('.'); font = loadFont("run.vlw"); textFont(font, 60); } void draw() { background(150, 50, 200); fill(46, 20, 2); text(c, 70, 175); fill(46, 20, 2); text(d, 70

Incrementing array values - Arduino

早过忘川 提交于 2020-01-15 06:43:49
问题 I'm trying to increment some array values: int counter[] = {0,0,0,0,0,0,0,0}; If the value of the number in position 0 reaches 25, then the value in position 1 is incremented by 1, and position 0 reset to 0. And so on - when index position 2 reaches 25 it increments position 3 by 1, and resets it's own value to 0. I'm doing some base26 incrementing - generating all the combinations of letters for a given number of letters. Ideally I'd like this to work infinitely (in theory) - a new array

Implementation of Arduino F() macro

巧了我就是萌 提交于 2020-01-14 10:36:13
问题 I'm trying to understand what the F() macro in Arduino actually does with PGMEM and RAM and what are the runtime implications. Can someone point me at the file that defines this macro? 回答1: This may be an older version, but one place where it is defined is Wstring.h as in here. You can find it yourself: if you installed Arduino you can search the installation directory. WString.h should be in hardware\arduino\cores\arduino\ 来源: https://stackoverflow.com/questions/15372821/implementation-of

手机语音控制led(Arduino)

假装没事ソ 提交于 2020-01-14 02:28:33
原理:利用HC-06蓝牙模块与手机APP进行通信。手机APP采用APPinventor进行制作, 结构及代码如下(有点丑,比较简陋,可自行美化): 连线方式对应如下: VCC--------3.3 GND--------GND TXD--------pin10 RXD--------pin11 Arduino代码如下: # include <SoftwareSerial.h> SoftwareSerial BT ( 10 , 11 ) ; void setup ( ) { pinMode ( 6 , OUTPUT ) ; BT . begin ( 9600 ) ; } char a ; int b = 100 ; void loop ( ) { if ( BT . available ( ) ) { a = ( BT . read ( ) ) ; if ( a == '1' ) { b = 100 ; analogWrite ( 6 , b ) ; BT . println ( "灯已打开" ) ; } if ( a == '2' ) { digitalWrite ( 6 , LOW ) ; BT . println ( "灯已关闭" ) ; } if ( a == '?' ) { BT . println ( "Send '1' to turn LED on" ) ; BT .

Arduino Ethernet Shield connection to socket server

一曲冷凌霜 提交于 2020-01-13 20:44:08
问题 I'm using an ethernet shield for Arduino to connect it to a socket server (different computer) so that I can receive messages from it to activate some routine. Here is my code: #include <Ethernet.h> #include <SPI.h> byte mac[] = { 0x90, 0xA2, 0xDA, 0x0F, 0x5A, 0x21 }; byte ip[] = { 192,168,1,11 }; //ip shield byte server[] = { 192,168,1,7 }; // ip server EthernetClient client; String readString; int ledPins[] = {19, 17, 2,3, 5, 6, 7, 8, 9}; // leds pins int pinCount = 8;// number of leds int

Arduino Ethernet Shield connection to socket server

走远了吗. 提交于 2020-01-13 20:43:51
问题 I'm using an ethernet shield for Arduino to connect it to a socket server (different computer) so that I can receive messages from it to activate some routine. Here is my code: #include <Ethernet.h> #include <SPI.h> byte mac[] = { 0x90, 0xA2, 0xDA, 0x0F, 0x5A, 0x21 }; byte ip[] = { 192,168,1,11 }; //ip shield byte server[] = { 192,168,1,7 }; // ip server EthernetClient client; String readString; int ledPins[] = {19, 17, 2,3, 5, 6, 7, 8, 9}; // leds pins int pinCount = 8;// number of leds int

Reading from serial port in a Ruby on Rails application hangs

不羁的心 提交于 2020-01-13 10:54:09
问题 I'm using the serialport gem to read from the serial port in my Ruby on Rails 3.2 application. The serial port itself is used to write data from an Arduino board. The gem is added to Gemfile . The port is initialized in application.rb : config.serial_port = SerialPort.new "/devttyACM0", 9600 config.serial_port.read_timeout = 100 The problem appears when I try to read from this port. @sp = ProjectName::Application::config.serial_port @sp.read The application hangs deadly. I've tried to perform

Reading from serial port in a Ruby on Rails application hangs

大城市里の小女人 提交于 2020-01-13 10:53:26
问题 I'm using the serialport gem to read from the serial port in my Ruby on Rails 3.2 application. The serial port itself is used to write data from an Arduino board. The gem is added to Gemfile . The port is initialized in application.rb : config.serial_port = SerialPort.new "/devttyACM0", 9600 config.serial_port.read_timeout = 100 The problem appears when I try to read from this port. @sp = ProjectName::Application::config.serial_port @sp.read The application hangs deadly. I've tried to perform