arduino

Arduinio sd on Ethernet shield not working at all

久未见 提交于 2019-12-22 18:28:45
问题 I am new to Arduino, and I have an ethernet shield with an SD socket on top, but it not seems to be working. I am just trying to run a simple sketch taken from the SD libraries example to get infos about the card, but the "card.init(SPI_HALF_SPEED, chipSelect)" part always fails. I have set the ChipSelect pin to 4, and set pin 10 to output, still nothing. My code: #include <SD.h> Sd2Card card; SdVolume volume; SdFile root; const int chipSelect = 4; void setup() { Serial.begin(9600); while (

Arduino基础学习总结

孤者浪人 提交于 2019-12-22 14:36:13
arduino设计 基本指令篇 ---数字输入输出接口 digitalRead(pin);//读值 digitalWrite(pin,HIGH);//写高或低 pinMode(pin,) //工作模式设置INPUT, OUTPUT, or INPUT_PULLUP上拉输入 ---模拟输入输出 analogRead() 读入模拟电压返回0-1023 analogReference();//参量配置INTERNAL、INTERNAL1V1、INTERNAL2V56 analogWrite(pin,value);//输出多大占空比 ---Advanced I/O接口 pulseIn(pin, value, timeout);//返回PIN引脚的高电平或低电平脉冲,timeout为时间限制。 ---Math部分 map(); long map(long x, long in_min, long in_max, long out_min, long out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; }类似于分辨率的放大缩小 constrain(x,a,b)//限制 abs;//绝对值 max,min;/最大最小值 sq(x);//x的平方 sqrt(x);//x的平方根 --

Serial message to integer on Arduino

筅森魡賤 提交于 2019-12-22 10:05:15
问题 I want my Arduino to receive an integer through the serial communication. Can you help me with this? It should be in a form like: int value = strtoint(Serial.read()); 回答1: There are several ways to read an integer from Serial , largely depending on how the data is encoded when it is sent. Serial.read() can only be used to read individual bytes so the data that is sent needs to be reconstructed from these bytes. The following code may work for you. It assumes that serial connection has been

xcode, c++ serial port with arduino

亡梦爱人 提交于 2019-12-22 09:48:40
问题 i’m making a very simple c++ program which send an angle to arduino through a serial port and then arduino apply that angle to a servo-motor. I know that Unix see serial ports device like a file, in fact this is the c++ code: #include <iostream> #include <unistd.h> using namespace std; int main() { int angole; FILE * arduino; do { arduino = fopen("/dev/tty.usbmodem3a21","w"); cout<<"\n\give me the angle\n\n"; cin>>angole; fprintf(arduino,"%d",angole); sleep(1); }while(angole>=0 && angole<=179

How to send serial data from Python script to Arduino on Windows - Nothing Works

岁酱吖の 提交于 2019-12-22 09:28:45
问题 I can't correctly send data over serial from a Python script to an Arduino Uno. I'm using 9600 baud, and the Arduino correctly resets, but it does not read the char I'm sending from the Python script. I call time.sleep() to ensure the reset on the Arduino does not interfere, and I'm using Windows 7. I should clarify by saying that my desktop is running the python script and connected via USB to the Serial of my Arduino Uno. I then have the RX & TX pins (pins 0 & 1) of my Uno connected to my

Arduino Android Bluetooth Communication

我们两清 提交于 2019-12-22 09:24:10
问题 I've made an app which connects to Arduino Mega 2560 by means of HC-05 Bluetooth module. I succeed in giving commands to Arduino via bluetooth, but the opposite communication doesn't apparently work. I don't know if the problem is in Arduino or Android side. Arduino sends messages with this simple instructions: #include ... SoftwareSerial bluetooth(12, 11); void setup(){ Serial.begin(9600); bluetooth.begin(9600); ... } void loop(){ ... bluetooth.listen(); while (bluetooth.available() > 0) {

Arduino Android Bluetooth Communication

我怕爱的太早我们不能终老 提交于 2019-12-22 09:23:01
问题 I've made an app which connects to Arduino Mega 2560 by means of HC-05 Bluetooth module. I succeed in giving commands to Arduino via bluetooth, but the opposite communication doesn't apparently work. I don't know if the problem is in Arduino or Android side. Arduino sends messages with this simple instructions: #include ... SoftwareSerial bluetooth(12, 11); void setup(){ Serial.begin(9600); bluetooth.begin(9600); ... } void loop(){ ... bluetooth.listen(); while (bluetooth.available() > 0) {

C++ Linux (Ubuntu) Writing to Serial Properly (For Arduino)

纵然是瞬间 提交于 2019-12-22 09:14:01
问题 I'd like to know if there is a standard way to communicate with the serial device that is efficient. Should I be using a standard library? If so, which one? Right now I'm fiddling around getting an LED to light up at a given amount based on number input. (Arduino code below). Just practice stuff. See my overly simple and inefficient test: #include <iostream> #include <stdio.h> using namespace std; int main() { FILE *file; //Opening device file int getnum; while (true) { file = fopen("/dev

Parsing code for GPS NMEA string

不羁的心 提交于 2019-12-22 08:58:02
问题 i am trying to parse the incoming GPGGA NMEA GPS string using Arduino uno and below code. What i am trying to do is that i am using only GPGGA NMEA string to get the values of Latitude, longitude and altitude.In my below code, i had put certain checks to check if incoming string is GPGGA or not, and then store the further string in a array which can be further parsed suing strtok function and all the 3 GPS coordinates can be easily find out. But i am unable to figure out how to store only

In C++, how do I write a 3-dimensional array?

此生再无相见时 提交于 2019-12-22 08:43:18
问题 Thanks for looking! Background I am building a quadcopter and am placing on each of it's four arms a strip of RGB LEDs which are individually addressable. There are 6 LEDs per strip. Further, there are six steps in a sequence to how I wish to toggle the lights so all six lights on the strip don't necessarily toggle at once. In pseudo code, here is what I am trying to create: someArray = A group of 4 LED strips {Strip 1: [ Step 1: [ LED 1: [R, G, B], . . ., LED 6: [R, G, B] ], . . ., Step 6: [