arduino

Python玩转Arduino——简单介绍

China☆狼群 提交于 2019-12-27 00:10:17
关于Python语言的介绍安装请参考 廖雪峰的Python教程 Python是一门解释型语言,虽然不能够像c语言一样编译上传到Arduino——什么你说MicroPython,我们再说Arduino呢——仍然是可以跟Arduino的玩耍的,就像scratch一样。 前言 Python玩转arduino的方式跟mblock的在线编程模式差不多的,都是先给arduino写入一个固件,然后操作,不同的是mblock是通过积木来向arduino下指令,这里我们用Python. mblock对arduino在线编程的步骤 连接arduino到电脑 打开mblock软件 选择对应端口 选择合适的控制板 然后我们就可以愉快的编程了. 用Python玩转Arduino 首先你要安装Python,并且确保安装了pip 然后我们要用到一个代码块 Python Arduino 原型API第二版 . This is a project based on the original Python Arduino Prototyping API . I started a fork and after a while the whole thing was getting too different to make a pull request so I just put it here. The old

Python 3 Convert String to Hex Bytes

烈酒焚心 提交于 2019-12-26 18:57:23
问题 I need to convert a simple string to a byte array which uses hex representation, just like that site: http://string-functions.com/string-hex.aspx This string then gets send via bluetooth using python and the arduino reads the individual bytes like this: char buff[1000]; int i =0; int typeByte = serial->read(); int data = serial->read(); while (true) { if (data == -1) continue; if (data == 254 || data == 10) break; buff[i++] = data; data = serial->read(); delay(10); } String buffer(buff); if

Python 3 Convert String to Hex Bytes

吃可爱长大的小学妹 提交于 2019-12-26 18:56:11
问题 I need to convert a simple string to a byte array which uses hex representation, just like that site: http://string-functions.com/string-hex.aspx This string then gets send via bluetooth using python and the arduino reads the individual bytes like this: char buff[1000]; int i =0; int typeByte = serial->read(); int data = serial->read(); while (true) { if (data == -1) continue; if (data == 254 || data == 10) break; buff[i++] = data; data = serial->read(); delay(10); } String buffer(buff); if

Arduino Live Serial Plotting with a MatplotlibAnimation gets slow

醉酒当歌 提交于 2019-12-26 03:14:05
问题 I am making a live plotter to show the analog changes from an Arduino Sensor. The Arduino prints a value to the serial with a Baudrate of 9600. The Python code looks as following: import matplotlib.pyplot as plt import matplotlib.animation as animation import serial import time ser = serial.Serial("com3", 9600) ser.readline() optimal_frequency = 100 fig = plt.figure(figsize=(6, 6)) ax1 = fig.add_subplot(1, 1, 1) # the following arrays must be initialized outside the loop xar = [] yar = []

System.TypeLoadException with Mono and ASP.NET in Arduino project

流过昼夜 提交于 2019-12-25 18:43:28
问题 I am trying to use a web page to control an LCD screen on an Arduino. The web page works when run from Visual Studio (2012), but when trying to deploy to my Apache server with mod_mono, I get this cryptic error. This is the complete error: Could not load type 'System.Web.UI.ScriptResourceDefinition' from assembly 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Description: HTTP 500.Error processing request. Details: Non-web exception. Exception

Control a python thread from outside

妖精的绣舞 提交于 2019-12-25 16:57:35
问题 I have a program, which needs to continuously run in the background, but be able to receive instructions to change. I have this thread running, which sends data to an Arduino and receives data back: class receiveTemp (threading.Thread): def __init__(self, out): threading.Thread.__init__(self) self.out = out def run(self): self.alive = True try: while self.alive: rec = send("command") self.out.write(rec) except BaseException as Error: print(Error) pass Now I need to change the command I send

How to update Serial.print statement in realtime using Arduino

北城以北 提交于 2019-12-25 16:55:32
问题 I have the following sketch, https://github.com/ipatch/KegCop/blob/master/KegCop-Bluno-sketch.c that I'm running on Arduino UNO compatible microcontroller. However I am trying to print statements while the flowmeter is in use with the following function, // flowmeter stuff bool getFlow4() { // call the countdown function for pouring beer // Serial.println(flowmeterPin); flowmeterPinState = digitalRead(flowmeterPin); // Serial.println(flowmeterPinStatePinState); volatile unsigned long

AT Commands fail to Execute in a program

泪湿孤枕 提交于 2019-12-25 12:53:52
问题 The Program is shown below: #include <SoftwareSerial.h> SoftwareSerial gprsSerial(7, 8); byte sensorInterrupt = 0; // 0 = digital pin 2 byte sensorPin = 2; // The hall-effect flow sensor outputs approximately 4.5 pulses per second per // litre/minute of flow. float calibrationFactor = 4.5; volatile byte pulseCount; float flowRate; unsigned int flowMilliLitres; unsigned long totalMilliLitres; unsigned long oldTime; void setup() { gprsSerial.begin(19200); Serial.begin(19200); pinMode(sensorPin,

Configuring Xbee S2 with XC-TU

做~自己de王妃 提交于 2019-12-25 11:59:37
问题 I'm trying to set up a very basic network using 2 Xbee modules. One as Coordinator and the other as Router. The Problem I am only able to send data from Arduino (Router) to XCTU (Coordinator). It's a mono directional communication. What's the correct configuration for these modules in order to establish a bidirectional communication? I have followed these tutorials and none of them worked. http://www.seeedstudio.com/wiki/Zigbee_Networking_with_XBee_Series_2_and_Seeed%27s_Products http://www

Arduino keypad 4x4 to LCD activate/deactivate (home security system)

北城余情 提交于 2019-12-25 09:18:44
问题 I have a problem with an activation/deactivation system for Arduino. I can get the code to activate or deactivate once I upload a fresh copy of the code, but once I activate it after upload and try to deactivate the security system, it only takes in 2 numbers and then prompts me to Wrong password. #include "Keypad.h" #include "LiquidCrystal.h" #include "Password.h" LiquidCrystal lcd(0,1,10,11,12,13); char newPasswordString; //hold the new password char newPassword[4]; //character string of