texts: Connecting Load combinator to HX711 then to Arduino

texts:
i'm currently a student and my project is to create a weighing scale using 50kg load sensors (x4) with HX711 amplifiers, load combinator and Arduino UNO. I've connected the load combinator and HX711 based on the picture below:

I'm wondering after this connection, how do i connect it to the pins of Arduino UNO and does anyone know the codes to make the load sensors work? Because currently i keep getting 0kg as the final value as well as the offset value.


texts: Changing parameters in Arduino without the IDE

texts:
I’m installing Arduino-based well monitors in my local community.  Each well is different and has slightly different parameters and several hardware variations.  Currently, when I need to make a program change I have to uninstall the Arduino, bring it back to my computer, reprogram it, then reinstall it.  I’m developing these units as I go so there are various refinements that arise as well. I’d love to be able to reprogram a unit in place.  It seems like it could be done with another Arduino but I don’t currently have the skills for that.  The second, less flexible, method would be to use dip switches to select various options.  This option is attractive but would limit me to only the options that I know of at programming time.  Is there a third option I haven’t thought of?  Has anyone else tried programming one Arduino from the other?
Edit: I’m primarily using Unos but I’m working on a low power version that will use a Mini Pro. The units are accessible as far as USB cables and such. However I don’t own a laptop.


texts:
Important note: the esp.deepsleep function uses microseconds, not milliseconds.

I posted another question here asking for clarification on how an RTC can be used to put a NodeMCU 12 to sleep for a long time (~24hrs or more).

This question concerns the use of ESP.deepSleep([microseconds]) with the NodeMCU 12 board.  There is a discussion here and I have followed the advice but have been unable to successfully implement the ESP.deepSleep() function using the Arduino IDE and a NodeMCU 12 board.

Initial findings:
-Connecting gpio16 (D0) to the RST pin causes a reset immediately upon entering sleep.  The entire boot process and loop are repeated over and over again.
-Simply using the ESP.deepSleep() function without gpio16-to-RST generates gibberish on the serial monitor and illuminates the red led on the board.

My code is here (I just drop "deepsleep();" where I want the sleep process to begin):

void deepsleep() {
  Serial.println("sleeping hr 1");
  ESP.deepSleep(3600000); //1hr
  delay(100);
  Serial.println("sleeping hr 2");
  ESP.deepSleep(3600000); //2hr
  delay(100);
  Serial.println("sleeping hr 3");
  ESP.deepSleep(3600000); //3hr
  delay(100);
  Serial.println("sleeping hr 4");
  ESP.deepSleep(3600000); //4hr
  delay(100);
  Serial.println("sleeping hr 5");
  ESP.deepSleep(3600000); //5hr
  delay(100);
  Serial.println("sleeping hr 6");
  ESP.deepSleep(3600000); //6hr
  delay(100);
  Serial.println("sleeping hr 7");
  ESP.deepSleep(3600000); //7hr
  delay(100);
  Serial.println("sleeping hr 8");
  ESP.deepSleep(3600000, WAKE_RF_DEFAULT);  //8hr
}

What is wrong with this approach and why am I (apparently) causing an error?


texts:
I have 1.8 TFT display for Arduino Nano and it changes color very slow. When I try to change the color of the whole screen I see how it changes color line by line. I use "Adafruit GFX graphics core" and "Adafruit ST7735" libraries to change colors.

Question: Slow refresh rate of 1.8 TFT display is due to limited computation capability of Arduino or 1.8 TFT display itself or library used?


texts: How to check whether my Arduino is working? And how to fix this?

texts: I tried my first project with Arduino Uno. But I can't upload any code. Power green LED is working and orange LED is always on, not blinking, and IC also getting hot. What can I do to fix this problem?


texts: How to connect two arduinos with smartphone wirelessly

texts: I'm working on a project that have two separate setups for Arduino, each Arduino read sensors and send data to smartphone. how to connect two Arduino then send all data to smartphone over Bluetooth?


texts:
I have a SIM808 module like this: https://www.banggood.com/SIM808-Module-GPS-GSM-GPRS-Quad-band-Development-Board-For-Arduino-p-1063106.html

The output header has 5 pins: GND/RX/GND/TX/VCC and I connected them as:

GND/VCC to a LiPo battery, 7.4V@1000mAh

RX->pin 14 (written on it TX3)

GND->to arduino GND

TX->pin 15 (written on it RX3)

and uploaded this code

#include <SoftwareSerial.h>

SoftwareSerial GSMSerial(15,14);    // RX, TX

void setup()
{

  GSMSerial.begin(19200);
  Serial.begin(19200);
  Serial.println("START");
}

void loop()
{
  if(Serial.available())
    GSMSerial.print((char)Serial.read());
  else  if(GSMSerial.available())
    Serial.print((char)GSMSerial.read());
}

But I'm not getting anything on it (when sending "AT" or anything else).

Any help is appreciated.

Thank you!


texts:
I'm trying to make a nema17 stepper motor work using ramps1.4 and A4988 driver.
But when I'm trying to rotate motor, it spins with almost no torque and constant shaking.

Motor 2-phase nema17 , Step Angle 1.8° .
Power supply 12v/60w.

Here is the sketch:
(I copied it from RepRap wiki , and removed everything except X Motor)

#define X_STEP_PIN         54
#define X_DIR_PIN          55
#define X_ENABLE_PIN       38

void setup()
{
  pinMode(X_STEP_PIN       , OUTPUT);
  pinMode(X_DIR_PIN        , OUTPUT);
  pinMode(X_ENABLE_PIN     , OUTPUT);
  digitalWrite(X_ENABLE_PIN, LOW);
}

void loop ()
{
  if (millis() % 10000 < 5000)
  {
    digitalWrite(X_DIR_PIN    , HIGH);
  }
  else
  {
    digitalWrite(X_DIR_PIN    , LOW);
  }

  digitalWrite(X_STEP_PIN     , HIGH);
  delay(1);
  digitalWrite(X_STEP_PIN     , LOW);
}

The wiring diagram:
(I have only X Motor plugged in)

and video: (Google Video link is dead @ 2017-02-09)


texts:
I connected everything properly. On the first try I did receive data as  I was supposed to. I then wrote some logic, re-uploaded and started receiving crazy spam.

My serial monitor is getting spammed with:

question marks if the variable is char, or;
25252525252 if the variable is int, or;
-1 if variable is String.

I'm monitoring at 38400 baud which is the same as my Serial.begin().

Any ideas ?

Code:

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

#define MIN_PULSE_WIDTH 650
#define MAX_PULSE_WIDTH 2350
#define DEFAULT_PULSE_WIDTH 1500
#define FREQUENCY 50

char data = 'a';

void setup()
{
  analogReference(DEFAULT);

  Serial.begin(38400);

  pwm.begin();
  pwm.setPWMFreq(FREQUENCY);
  Serial.println("hello world");
}

void loop()
{
  data = Serial.read();
  Serial.println(data);
  Serial.flush();
  if (data == 'a'){
    pwm.setPWM(0, 0, pulseWidth(90));
  }
  if (data == 's'){
    pwm.setPWM(0, 0, pulseWidth(30));
  }
  delay(1000);
  //printing time in seconds
}

int pulseWidth(int angle)
{
  int pulse_wide, analog_value;
  pulse_wide = map(angle, 0, 180, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
  analog_value = int(float(pulse_wide) / 1000000 * FREQUENCY * 4096);

  return analog_value;
}


texts:
Are there "user intefrace" solutions for Arduino based gadgets? Solutions, that is, accepted as something more or less standard by the community. I am unaware of the relevant keywords, if there are some, so let me explain:

A modern computer has a standard keyboard and a standard mouse, which together cover 99.99% of all the imaginable needs. Of course, you can plug the Arduino gadget into a computer via USB and enjoy full control via the Firmata protocol, for instance. What are the more lightweight solutions, if a laptop is too heavy, yet a pair of buttons not smart enough? In the range of smartphone to something calculator-like?

Sorry for being vague; it's a newbie question.


texts: Power a Raspberry Pi 3 from an Arduino Uno

texts:
I would like to power my Raspberry Pi 3B using an Arduino Uno.

I have been able to do this by connecting the 5v on the Arduino to the 5 V on the Pi and connecting the GND to GND, and the Pi turns on. But I get a constant under voltage sign.

How can I get the Arduino to output the right amount of power (5 V and 2.5 A)?


texts:
I am trying to write to a XML file.

I can write some values but limited. When I add an extra line or value the xml file stop updating and all commands I have after the xml.close(); aren't executed

  File xml = FileSystem.open("/mnt/sda1/Data/data.xml", FILE_WRITE); // open the file
  if(xml){
    Serial.println("XML Opened");
    xml.println("<?xml version=\'1.0\' encoding=\'UTF-8\'?> ");
    xml.println("<sea>");
      xml.println("\t<temperatures>"); //ASCII control codes (TAB)
        xml.print("\t\t<water>");
          xml.print(waterTmp);
        xml.println("</water>");
      xml.println("\t</temperatures>");
    xml.println("</sea>");

    xml.close();
  }
  else{
    Serial.print("XML Error");
  }

For e.g if I add

xml.print("\t\t<air>");
xml.print(airTMP);
xml.println("</air>");

If this lines of code are alone in a sketch everything is good.
Another strange thing is if I add the same line twice or more times it can write them to the file.

Do you have any idea how this problem could be solved?


texts: Windows Driver for Arduino error code 22

texts:
I'm trying to use avrdude to load an Arduino program with the console, but I have a Windows 7 x86 Professional with Service Pack 1 (old PC).  When I install the Arduino driver that comes with the IDE manually, with pnputil.exe, in the Windows 7 on PCs that have these processors:

Intel(R) Pentium(R) 4 CPU 2.80GHz
Intel(R) Core(TM)2 Duo CPU E6400 @ 2.13GHz
Intel(R) Core(TM)2 Duo CPU E8400 @ 3.00GHz

I see that the drivers don't work properly.  I get error code 22 in some cases.  And in other cases, the Windows system disables the Arduino in the Windows devices and prevents enabling the COM device.
But, if I install the Arduino IDE or manually install the Windows driver on Core i3, Core i5 and i7 in Windows 7, 8 , 10, the response is perfect.  But, in the others I get error code -22 or Windows doesn't allow to enabling the device.
Has anyone had the same problem and how did you solve it?
Thanks.


texts: How to convert byte array into a single variable

texts:
In this code i am taking the TID data(20bytes of 160bits) in the form of array according documentation and and its working correctly and getting the output of RFID tags.

Now I just need your guidance that how can i convert the array of 20 Bytes into a single variable or into a double long datatype? or another. Because I have to push it on to my MySQL database server for further processing.

I had tried the following code which works fine

byte x[10] = "450210921";
long result = atol(x);
Serial.print("long value of the byte is: ");
Serial.println(result);

but when i put the above code into my main code, getting not any error and I am not getting the required output.!

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  byte response;
  byte myTID[20]; //TIDs are 20 bytes
  byte tidLength = sizeof(myTID);

  //Read unique ID of tag
  response = nano.readTID(myTID, tidLength);
  if (response == RESPONSE_SUCCESS)
  {
    for(byte x = 0 ; x < tidLength ; x++)
    {
      if(myTID[x] < 0x10) Serial.print("0");
      /*temp[x]=(myTID[x], HEX);*/
      //Swapping values into temp variable
      temp[x]=myTID[x];
      Serial.print(temp[x]);
    }
    /*byte x[10] = "450210921";*/
    //Convert a whole array into a single long variable
    long result = atol(temp);
    Serial.print("long value of the byte is: ");
    Serial.println(result);
  }
  else
    Serial.println("Failed read");
}


texts:
I was thinking of buying another Arduino, and the Leonardo looks appropriate.

However I am confused! The Comparative Tables seems to show 2 different Leonardos. (This table is very difficult to read with tiny black text on a grey background, and no key to the column headings.)

There appear to be different models "R3" and "R4" from different retailers and Element14 seems to have a "U4". Can anyone clarify the differences?

I assume I can use the Uno Prototyping shield on the Leonardo.


texts:
Does anyone know if there is an Ethernet shield is compatible with the Arduino Ethernet shield (R3)? The R3 does not seem to be in production anymore and I need a replacement shield. Found some from Velleman, or maybe Ethernet Shield 2?

Arduino Ethernet Shield R3
Arduino Ethernet Shield 2
Velleman Ethernet Shield


texts: NRF24L01 Direct Communication Library Logics

texts:
Actually I'm using the RF24 Library mantained by TMRh20 (https://github.com/TMRh20/RF24).
I'm trying to get some type of direct communication between multiple modules working, but I don't want to use the RF24Network Library (https://github.com/TMRh20/RF24Network) which creates a mesh of connections.

I currently have several arduinos that have to communicate between them. Every arduino has its own address starting from 0x0001 (0x0000 is for a main module that manages everything) and finishing to 0xFFFF.
I want to directly communicate between the two NRF24L01+ modules without any intermediator, because I don't have problems of distance.

The main thing that I want to be able to do is communicate directly not with just one module, but choose if I want to broadcast to all the modules in an area (I know that it can be done with range power modifications in the code) or talk with just one module.

What is the best way to do this type of communication?


texts: Arduino LCD changing contrast only makes black boxes less readable i.e. less in contrast

texts:
I have seen similar issues posted here but none match my problem exactly.

I have a starter kit and a 16x2 LCD screen that only shows black boxes in the top row using the following code:

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  lcd.begin(16, 2);
  lcd.print("hello, world!");
}

void loop() {

}

All tutorials use a potentiometer to change the contrast but I don't have one so I decided to use chain several resistors. When doing so, the contrast indeed changes, but it changes as a whole. The black boxes become less readable i.e. less in contrast (more vague) but stay completely black.

Just to make sure, I have a cable from the + tray (with 5v) to the VDD port and - tray (with GND) to the VSS port. The K port is on the - tray as well and the A is with a 220 ohm resistor on the + tray.

I have tried no, 3k, 4k, 3220, 10k and 100k ohm on the v0 port to change the contrast.

What could be wrong? Any help is appreciated.

Edit photo:


texts:
I am new to electronics and especially Arduino-based products. I am currently trying my hand at using 5 segments of WS2812 RGB LEDs and using a Nano to control them. I included the picture below for the pin numbers.

If I wanted to run 5 groups of LEDs and use a library like the Adafruit Neopixel or Fastled to control the leds, what would be the best way of wiring them up to the Nano?

I am under the impression that the positives should all be connected to pin 27, the 5v pin, with a 1000 µF 25V capacitor. The ground wires will all be connected together to pin 04, Ground. The data pins will be wired to pins 6, 8, 9, 12 and 13 and each will have a 470 ohm 1/2W resistor on each pin.

I am unsure whether any of the other pins can be used for data pins. The input voltage will vary since this is used on a multi-rotor that I am building. The battery voltage will vary from 12.6V all the way down to maybe 9 volts. I was thinking of using a step down adjusted to 12V to keep the voltage at or under 12v and that will be connected to pin 30. I would love to hear if there are any better ways of wiring this project up.

Also would it be a better idea to power the LEDs from a 5V dedicated source and just use the Nano for the data pin connection? I will only be using roughly 30-40 WS2812s.


texts: Cannot write to HID USB device (Arduino, V-USB, HidSharp)

texts:
I am currently prototyping an HID USB device using Arduino Nano and V-USB library. The problem is that although I can read from the device I cannot write to it.
Here is the schema:

As for the firmware I'm using the hid-serial library.
Here is the Arduino code:

#include <HIDSerial.h>

HIDSerial serial;

unsigned char buffer[32];

void setup() {
  serial.begin();
}

void loop() {
  if(serial.available()) {
    int size = serial.read(buffer);
    if (size!=0) {
      serial.write((const uint8_t*)buffer, size);
      serial.write('\n');
    }
  }
  serial.poll();
}

Here is the HID report descriptor:

    0x06, 0x00, 0xff,              // USAGE_PAGE (Generic Desktop)
    0x09, 0x01,                    // USAGE (Vendor Usage 1)
    0xa1, 0x01,                    // COLLECTION (Application)
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
    0x75, 0x08,                    //   REPORT_SIZE (8)
    0x95, 0x08,                    //   REPORT_COUNT (8)
    0x09, 0x00,                    //   USAGE (Undefined)
    0x82, 0x02, 0x01,              //   INPUT (Data,Var,Abs,Buf)
    0x95, HIDSERIAL_INBUFFER_SIZE, //   REPORT_COUNT (32)
    0x09, 0x00,                    //   USAGE (Undefined)
    0xb2, 0x02, 0x01,              //   FEATURE (Data,Var,Abs,Buf)
    0xc0                           // END_COLLECTION

And lastly, here is the code running on host (.NET/C# using HidSharp library):

var devices = DeviceList.Local;
var hidDeviceCollection = devices.GetHidDevices(this.vendorId, this.productId).ToList();
var device = hidDeviceCollection.First();
var stream = device.Open();
var buffer = new byte[9];
buffer[0] = 0;
buffer[1] = 42;
stream.Write(buffer);
buffer = stream.Read();

When I run the code above despite stream.CanRead being true I receive an exception "Can't write to this device.". However if I change the code to the "Hello World" example provided by the library I can read from the device without issue.


texts:
Arduino Uno user here

I am building a project with 4 analog inputs A0 dose not work. A1 A2 and A3 work perfectly fine! But for last input when I connect to A4 or A5, then they do not go to zero. They are stuck between 400 to 900. Even when connected to arduino ground it gives 400 instead of 0.

Am I missing something here cause the circuit for A4 connected to A3 gives perfect input value. They both work fine as output.  Same situation with A5.

Is there another way to get one more Analog Input without multiplex?

Thank you!


texts: How do I run a bipolar motor with an arduino uno?

texts:
At the risk of looking like a complete idiot on the internet, I'll preface with this; I'm incredibly new to this. I'm new even to coding, and not sure what questions I should be asking.

I'm trying to run a bipolar motor with an Arduino Uno. I'm fairly sure it should be as simple as set a pin to high, plug the motor into that pin and a ground and it should run. I did this a week ago, and it worked then.

Now I'm trying to essentially run a modified version of blink with this motor running instead of the LED. Running the code with pin 13 as my positive does still flash the LED. If I set my pin to high with the motor, the motor no longer runs. However, It does run when plugged into the 5V and ground. The motor also runs straight off of the two poles of a 9V battery.

I'm unsure what I'm doing wrong. Do I need to step up the voltage of my pins somehow?

Thanks in advance.
-Alec Rosso

Edit 1:Here's the code:

int motorPin1 = 13;
int interval= 5000;

void setup() {
pinMode(motorPin1, OUTPUT);
digitalWrite(motorPin1, HIGH);
}

void loop() {
digitalWrite(motorPin1, HIGH);
delay(interval);
digitalWrite(motorPin1, LOW);
delay(interval);
}

As far as voltage or current specifications, it says DC 12V.

Edit 2: it is not a stepper motor. The serial number is TS-32GZ370-950. It's apparently a "DC geared motor."

Final Edit: I've got it working using an L298. I used a 9-volt battery in addition to my arduino's 5 volts, and everything works like a dream. Thank you for your help.


texts: How do I know when filter coffee machine is finished by using any sensor?

texts:
I have a filter coffee machine that seems like the following link ;
https://www.electrolux.com.tr/kitchen/small-kitchen-appliances/coffee-makers/coffee-maker/ekf5300/
and I would like to send a message to the machine users by using any development board(like Arduino or NodeMcu) when the machine is finished.
I haven't found a way to detect when the machine is finished. (I also don't want to do any physical change on the machine, like adding any cable or opening in the machine. I can use any sensor or so on).
How can I do that? Any advice?


texts: Is it possible to power this 12V Wind Speed Sensor with a 5V battery?

texts:
I have a battery pack used to charge mobile phones. It's capacity is 13,000mAh and it has two output ports. Both are 5V but one is 1A and the other 2.1A
It also has an Input port of 5V 1A. (To which I will connect a solar panel).

I want to be able to power this Adafruit Feather M0 as well as this Wind Speed Sensor Wind Speed Sensor Voltage Type(0-5V) SKU:SEN0170. Is it possible and if it is how?


texts: Converting ESP32 SPI code to Arduino for MAX6921 IV-18 driver board

texts:
I purchased a IV-18 VFD tube driver module, which came with some example code for an ESP32 board. The driver module has a 20 output MAX6921 serial chip to drive the vacuum tube. I want to use this driver module with an Arduino Uno and then eventually a Raspberry Pi.
I think I have a very rough understanding of the electronics and demo code, but cannot seem to get my SPI calls to work. Rather than trying to translate the demo code in its entirety, my first goal is to just get one segment to light up.
Quick background
The IV18 tube has 9 grids. The first grid has only a dot and a dash, but the remaining 8 grid have 7 segments and a decimal point.

To light a segment, you provide power to the segment pins / decimal point and to the grid for that segment. To display several numbers, you have to quickly cycle through lighting each of the grid positions and the relevant segments for that position. If you cycle through this fast enough, the human eye sees the whole grid with numbers (persistence of vision).
What I have tried
So far, I have made the connections from the Arduino Uno to the driver board
Driver GND   - Uno GND
Driver 5V    - Uno +5V
Driver Din   - Uno digital pin 11 / MOSI
Driver CLK   - Uno digital pin 13 / SCK
Driver LOAD  - Uno digital pin 2
Driver BLANK - Uno digital pin 3
Driver Dout  - Not connected

The example code has hex codes which I believe are then translated to a 24 bit buffer (although only 17 bits are required) to send via SPI to set the MAX6921 outputs HIGH or LOW.
I think the bits required are as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

G7
G6
G5
G4
G3
G2
G1
G0
SEG_G
SEG_F
SEG_E
SEG_D
SEG_C
SEG_B
SEG_A
SIGN

DP

So to light the number 8 in the righthand most grid, I assumed I'd need the 8th bit high (grid) and bits 9,10,11,12,13,14 and 15 for the 7 semens for the "8".
In my setup function, I call SPI.begin and then SPI.transfer with what I assumed was the matching binary data (from right to left, I think because of the bit order LSB/MSB?):
SPI.transfer(0b000000000111111110000000);
This lights the first grid (the one after the degree and minus sign) but not what I want - I see some segments in the leftmost grid (the full grid, not the grid with the dot and minus) but these light in a different pattern each time  (varies each time I reset or re-upload which I think is to be expected as I'm pushing data to the MAX6921 each time).
This is my code so far
#include "SPI.h"

#define DISP_CLK 13   // White - SPI SCK
#define DISP_DATA 11  // Yellow - SPI MOSI
#define DISP_LOAD 2   // Blue
#define DISP_BLANK 3  // Green

void setup() {
  Serial.begin(9600);
  Serial.println("IV18 Test");

  SPI.begin();

  pinMode(DISP_BLANK, OUTPUT);
  digitalWrite(DISP_BLANK, LOW);

  pinMode(DISP_LOAD, OUTPUT);
  digitalWrite(DISP_LOAD, HIGH);

  SPI.transfer(0b000000000111111110000000);
}

void loop() {

}

I'm pretty sure the two fundamental things I have wrong here are the bits of data to send and then the correct use of the SPI.
Can someone please help me to understand the ESP32 code properly, and ideally help me get the correct data to send via SPI so that I can light up the segments & grid positions that I expect to.


texts: Problem in fetching http get request after put float number

texts:
I have this codes that works correctly!

#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>

#define PIN_TX    7
#define PIN_RX    8
SoftwareSerial mySerial(PIN_TX,PIN_RX);
DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,
char http_cmd[] = "GET /index.php?lat=*******&long=******* HTTP/1.0\r\n"
                        "Host: 04d1a36d.ngrok.io\r\n"
                        "\r\n";
char buffer[512];

void setup() {
  mySerial.begin(9600);
  Serial.begin(9600);
    while(!sim808.init())
  {
      Serial.print("Sim808 init error\r\n");
      delay(1000);
  }
  Serial.print("Sim808 init Success\r\n");
  delay(3000);

  //*********** Attempt DHCP *******************
  while(!sim808.join(F("cmnet"))) {
      Serial.println("Sim808 join network error");
      delay(2000);
  }

  //************ Successful DHCP ****************
  Serial.print("IP Address is ");
  Serial.println(sim808.getIPAddress());

  //*********** Establish a TCP connection ************
  while(!sim808.connect(TCP,"39c309ae.ngrok.io", 80)) {
      Serial.println("Connect error");
  }
  Serial.println("Connection success");

  //*********** Send a GET request *****************
  Serial.println("waiting to fetch...");
  sim808.send(http_cmd, sizeof(http_cmd)-1);
  while (true) {
      int ret = sim808.recv(buffer, sizeof(buffer)-1);
      if (ret <= 0){
          Serial.println("fetch over...");
          break;
      }
      buffer[ret] = '\0';
      Serial.print("Recv: ");
      Serial.print(ret);
      Serial.print(" bytes: ");
      Serial.println(buffer);
      break;
  }

  //************* Close TCP or UDP connections **********
  sim808.close();

  //*** Disconnect wireless connection, Close Moving Scene *******
  sim808.disconnect();
  delay(5000);
  }
  void loop(){
  }

Actually i want send two numbers instead of ****** in this line:

char http_cmd[] = "GET /index.php?lat=*******&long=******* HTTP/1.0\r\n"
                        "Host: 04d1a36d.ngrok.io\r\n"
                        "\r\n";

to 04d1a642.ngrok.io/index.php for inserting in a database.

but when i use

  sprintf

like this:

void setup(){
sprintf( http_cmd, "GET /index.php?lat=%f&long=%f HTTP/1.0\r\n"
                        "Host: 04d1a662.ngrok.io\r\n"
                        "\r\n", 36.423156, 48.526484);
.
.
.

The module doesn't fetch to server for get response!


texts:
How to increase current in O/P port in Arduino uno ?
to make it 200mA How I can do this?
It can in proggraming add more current
Which sample way to increase current ?
To control 2 Dc motor which normally work with 3 AA battery
Thanks


texts: Issue with If statement and boolean logic

texts:
I'm trying to control motor based on rain sensor and my own build anemometer. It should only controlling motor clockwise/CW for open the roof if there are no rain (indicated by value above 900) AND the wind speed below 4 km/h. If there are raining (analog value below 650) and/or wind speed above 4 km/h the motor should spin counterclockwise/CCW. I succeed to rotate the motor CCW if rain and/or high wind speed happen, but when the motor hit the limit switch for stopping the motor, motor only stop for maybe 2 seconds and then back rotating CW (open the roof), even the wind still above 4 km/h. The roof should be open only when there is no rain (analog value above 900) and the wind speed below 2 km/h. Here is my If Statement logic program:

if ((analogRead(rain) < 650 || (Wind > 4)){
  motor_closed();
}

else if (analogRead(rain) < 650 && (Wind > 4)){
  motor_closed();
}

else if (analogRead(rain) < 650 && (Wind < 2)){
  motor_closed();
}

else if (analogRead(rain) > 900 && Wind > 4){
  motor_closed();
}

else if (analogRead(rain) > 900 && Wind < 2){
  motor_open();
}

Did I make mistake when using && boolean operator? Or its something else?


texts: Sending array of bytes using serial communication from Mega 2560 to ESP 8266

texts:
The array is 16 analog inputs, till now these inputs are not connected to anything so they are random, except the first three elements of the array, connected to GND, in order to see the beginning of the array. The 2560 is continuously sending this array.
When using certain delay in the 2560 at each loop, it seems the array is received always correctly in ESP8266.
But with no delay, occasionally, the three zeros doesn't appear in the first 3 positions of the array, and are for example, in positions 7,8,9.
What is the explanation of this?


texts: Need help with the syntax for a function that takes a closure

texts:
My C++ is very out-of-date. (20+ years, before C++ had closures).

I'm a senior SW engineer, and I spent several hours yesterday trying to figure this out, but I could not work it out.

The background:

I'm trying to create a class, ClosureButton, that is a subclass of another class, ArduinoObject. (An ArduinoObject has setup(), start(), stop(), and loop() methods so that the main program can invoke it.)

(C++ uses the terms closure and lambda to mean different things. In other languages the terms are interchangeable. Forgive me if I'm not using the correct term.)

A ClosureButton's constructor would take a pin number, and a closure with a bool parameter (pressed). I would save that closure to a member variable. When the button's state changed, it would invoke the closure and pass the new button state to the closure.

The question:

I need help with the syntax for the constructor, as well as how to declare the instance variable that would hold the closure.

The constructor would look something like this:

ClosureButton::ClosureButton(uint8_t pin, _unkonwn_syntax_ closure);

(Where I need help with the _unkonwn_syntax_ bit.)

Then I need to declare a member variable on my ClosureButton to hold the closure:

class ClosureButton: ArduinoObject {
  //other stuff
  _other_unkonwn_syntax_ closure;
}

Again, I need help with the syntax to declare a member variable closure of type "closure that takes a bool parameter". (The _other_unkonwn_syntax_ bit.) At this point I don't think my closure will capture variables from its enclosing scope, but at some future date I might need to do that, so help with that would be appreciated as well.)


texts: Adrudio Due: How do MCU components USARTx & UART relate to board pins TXn/RXn?

texts:
I'm making USART support for SAM3x8e based Arduino Due board.
I looked into arduino source code, exactly

arduino-1.5.7/hardware/arduino/sam/variants/arduino_due_x/variant.cpp

and see that for Serial0 UART component is used, for Serial1 USART0 is used, for Serial2 - USART1 and for Serail3 - USART3. The USART2 is not even mentioned.

Why is this done that way?
I would like to realize what those comonents (USARTx & UART) are? Is UART is the subset of one of USARTs?
What is relation between USARTn & UART components and arduino board's TXn/RXn pins? Exactly, what pins are those component mapped to?

Thanx.


texts: void loop followed by other "void" expressions

texts:
I hope this is a simple request from a newcomer to Arduino and programming. I have understood that once a program enters a void loop section, it loops round indefinitely. However I have recently seen examples of sketches where another void $$$$$ section follows the closure (by}) of the void loop. As I write this, I am looking at one example concerning a 7 segment display where "void Num_Write(int)" follows the closure of the void loop. If the "loop" section does just that, as I have been lead to believe, how is a following section accessed?

Thank you,
Rob


texts: How can I get ultra clean dc wall power for my arduino project?

texts:
I'm doing an rfid project that requires a read range of at least 5 inches or about 13cm.  I'm using a nano with a usb port, a rfid reader from priority 1 design and a large antenna. The problem I'm running in to is that when I power the project from the usb port I get a pretty decent read range of 11-13cm. But when I power the project from a DC power supply the read range drops considerably.

After a lot of testing with various power supplies I believe that all my power adaptors are dirty enough to cause rf interference and reduce the range.  Powering the project with a 9v battery and a 5v power regulator gives me really good range: 18cm with the largest antenna.  But I need plug in power.

So how can I power this project in a way that gives me ultra clean power?

I tried that same 5v regulator with a 5v adaptor and still had short read range.
Someone suggested adding a smoothing capacitor between V+ and Gnd but I wouldn't know what size.  I'm not an EE - I'm just a coder with a soldering iron.
Is there a better power supply I can get?

[EDIT] Also just FYI, when I connect even only the ground wire the the computers USB port I get a much farther read range. So..

Could it be a case of needing to ground the circut better as the switching power supplies only have 2 prongs and probably no real "ground". (Or am I making stuff up?)

[EDIT 2] What about a rechargable situation where my wall adaptor keeps a litium charged and the litium supplies clean power to the circuit?

Also I now know that I can charge my whole circuit with anything from 5 to 12 volts. In fact it would be better to have more in the 7 to 12 range than strictly 5v.

[UPDATE 3] Since this project is in my wall I was able to ground essentially to "earth" and that cleared up the noise. See this question as well: https://electronics.stackexchange.com/questions/230024/grounding-dc-project-to-clean-rf-noise


texts:
I'm using the Arduino software to create a Morse code decoder using the  serial monitor.

I enter a Morse code such as .- as a text string and it's displayed in the LCD as a alphanumeric text. So if I enter .- into the serial Monitor, A is displayed on the LCD. But it only works for single symbols, not the dot and dash together.

Is there a way to make the if statement as seen below accept both the dots and dashes together?

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
  lcd.begin(16, 2);

 Serial.begin(9600);
}

void loop()
{
  char schar;

  if (Serial.available())
  {
    schar = Serial.read();

    Serial.write(schar);

    if (schar== '.-' ){
      Serial.write('A');
      lcd.print('a');
    }
  }
}


texts: Turning all 35 leds on sequentially with MM5451

texts:
I've been struggling for a long time trying to get the MM5451 chip to light up all 35 leds sequentially without any luck.  I've had intermittent help from the arduino forum, someone on youtube, and even found source code on here.  But all I've been able to accomplish is either to get all the lights lit up at once, or every other led lit up at once, or having two sets of 8 leds lighting up sequentially together.  I can't figure out how to get all of them lit on and off sequentially.  I'm sure it has to do with shifting bits but can't figure out how to do this.  Here's two sets of code that either light two sets of 8 bits together sequentially, and another program that lights every other led all at once.

Sequential lighting of two sets of 8 bits

#define CLK 2 // to MM5451 pin 21
#define dataBit  3 // to MM5451 pin 22

 byte singleled[]=  {1,2,4,8,16,32,64,128};
//   0b00000001, 0b00000010, 0b00000100,
 //  0b00001000, 0b00010000, 0b00100000,
 //  0b01000000, 0b10000000, 0b11111111 };

  byte singleled2[]=  {1,2,4,8,16,32,64,128};
 //  0b00000001, 0b00000010, 0b00000100,
 //  0b00001000, 0b00010000, 0b00100000,
 //  0b01000000, 0b10000000, 0b11111111 };

void setup() {
  pinMode(CLK, OUTPUT);
  pinMode(dataBit, OUTPUT);
  digitalWrite(CLK, 0);
  digitalWrite(dataBit, 0);
  Serial.begin(1200);
}

// the loop routine runs over and over again forever:
void loop() {

  for (int i=0; i<8; i++)   {
        // start bit
    digitalWrite(dataBit, 1);
    pulseCLK();
    // the "+ 0x80" turns on DP
    ssrWriteLSB(singleled2 [i]); // MOD myCount = 0-9
    ssrWriteMSB (singleled [i]); // eight LEDs binary count 0-255
      delay(500);
   // ssrWriteMSB(myCount);
    //Serial.println(myCount);
    delay(500);
   // Serial.println(myCount);
    zeroWrite(29); // pad remaining bits with 0s
    delay(500);
  }

} // end loop

void pulseCLK()   {
  digitalWrite(CLK, 1);
  digitalWrite(CLK, 0);
}

// LSB out first!
void ssrWriteLSB(byte value)   {
  Serial.println(value);
  for(int x =0; x < 8; x++)   {
    byte temp = value & 0x01;
    if (temp == 0x01)   digitalWrite(dataBit, 1); // data bit HIGH
    else digitalWrite(dataBit, 0); // data bit LOW
    pulseCLK();
   value = value >> 0x01; // shift right
  }
}

// MSB out first!
void ssrWriteMSB(byte value)   {
 Serial.println(value);
  for(int x =0; x < 8; x++)   {
    byte temp = value & 0x80;
    if (temp == 0x80)   digitalWrite(dataBit, 1); // data bit HIGH
    else digitalWrite(dataBit, 0); // data bit LOW
    pulseCLK();
    value = value << 0x01; // shift left
  }
}

void  zeroWrite(byte num1)   {
  digitalWrite(dataBit, 0); // data bit LOW
  for(int x = 0; x < num1; x++) pulseCLK();
}

Turns on every other light all at once:

#define dataBit 3
#define clk 2

void setup()  {
  Serial.begin(1200);
  pinMode(dataBit, OUTPUT);
  pinMode(clk, OUTPUT);
  digitalWrite(dataBit, 0);
  digitalWrite(clk, 0);
}

 void loop() {
     //digitalWrite(dataBit,1);
     for(int index=0; index < 36; index++)  {
          digitalWrite(dataBit,1);
          digitalWrite(clk,1);
          digitalWrite(clk,0);
          digitalWrite(dataBit,0);
          digitalWrite(clk,1);
          digitalWrite(clk,0);
      }
  }

Thanks in advance.

Bryan


texts:
I've recently got back to my Uno. I tried compiling my program and got the following error:

Arduino: 1.6.6 (Windows 8.1), Board: "Arduino/Genuino Uno"

avr-g++: error: missing filename after '-o'

exit status 1
Error compiling.

This happens on any of the programs I've tried to compile/upload.
I've searched around on Google but I have gotten no definite answers and how to fix this or what has caused this? Does anyone have an idea on what I could do?


texts: Trinket: Battery + USB at the same time?

texts:
Is it allowed to have battery and USB connected to the Trinket(3.3V) at the same time?

I am using the battery to also power other components, so always disconnecting power, hooking USB to re-program and vice-versa is quite time consuming (and I fear to ruin the connectors).


texts:
So I am trying to create a code for an outlaw pinewood derby car. It is using a brushless esc with reverse for a ducted fan. The car has a push button on the front along with headlight and brake light LED's.

My goal is to push the front button 5 times to activate the car, then place it against the gate (which will press the front button once again and keep it pressed until the gate falls and the race begins). Once the button is released I want the fan to turn on and push the car down the track. once a certain amount of time passes (enough time to cross the finish line, I will get this info once I get a chance to do some test runs, but for now let's say 1.5 secs) it will reverse the fan (to act as a brake) for another certain amount of time, as well as activate the brake lights. then turn off the fan completely.

A buddy and I have been trying to write a code for it but are at a loss.

Any suggestion or input would be greatly appreciated.

#include <Servo.h>                    //Use the Servo library for generating PWM
Servo ESC;                            //name the servo object, here ESC
int headLightLED = 7;                 // White LED headlights
int brakeLightLED = 15;               // Red LED tailights
int throttle = analogRead(A0);        //Read the voltage from POT
int DigitalPot = 6;                   //Digital potentiometer used to map ESC
int potValue = A0;                    // value from the analog pin
int MicroSwitch = 9;                  // Front momentary push button

void setup()
{
pinMode (headLightLED, OUTPUT);       // set headlights to output
pinMode (brakeLightLED, OUTPUT);      // set tailights to output
pinMode (DigitalPot, OUTPUT);         // Set digital potentiometer to output
pinMode (MicroSwitch, INPUT);         // set front switch to input
ESC.attach(10,1000,2000);             // Generate PWM in pin 10 of Arduino
delay (100);
ESC.write(10);                        // Activate ESC
delay(3000);                          // Wait for ESC to boot

throttle = map(throttle, 0, 1023, 0, 180); //Map the values of 0-1023 from pot to 0-180 bcs servo works only from 0-180

     delay(1000);
    digitalWrite(DigitalPot, LOW);       //Send mininum signal to A0
    analogRead (potValue);
    delay(1000);
    digitalWrite(DigitalPot, HIGH);    // Send Maximum signal to A0
    analogRead (potValue);
    delay(1000);
    digitalWrite(DigitalPot, LOW);       //  Return to zero throttle
    analogRead (potValue);
    delay(1000);
}

void loop()
{
    if (MicroSwitch == HIGH){
      int timeLapsed = millis();
    }else(MicroSwitch == LOW);
ESC.write(throttle);                   // based on the value of throttle generate PWM signal
 digitalWrite(throttle, 180);               // Full Speed
 delay(1500);
  digitalWrite(throttle, 0);                 // Full Reverse
  digitalWrite (brakeLightLED, HIGH);        // activate brake lights
  delay(1500);
  digitalWrite (throttle, 90);               // STOP
}


texts:
im using 4 channel relay to switch the motor pump.  but when the arduino output is high and i check first with led. the led behavior were high too but when i attached to the relay input IN1,  the relay were low.  its like reversed action(the arduino is high, but relay was low then when arduino output is low,  suddenly the relay was high.  i try to edit the code hoping if i set arduino output is low then relay will be high but its still the same,  its reversed.  arduino output is low but the relay become high.  is there any way to make the relay to become high when the digital output is high?

however.. i didnt have the the actual circuit act but im using the digital pin as the output and some switches.  the project im work on is the automatic aquarium pump and water change which is the pump will automatically refill the water actuated by the float switch and will automatically drain the water and refill the new water in certain time.

im using pin 13 as the output.. and the pin 1 as the input which is a switch
as in picture im using a led as a output. but as soon i change to the relay, it become what i just said at the above


texts:
I´d like to connect my Ethernet2 with WIZ550 using DHCP but instead of Local IP, I want to use Hostname.

This is my code, it works. I get a Local IP Address and I can connect to Arduino using this IP, but I don't know how to setup hostname.

void setup() {

  // Monitor Serial begin
  Serial.begin(9600);
  Serial.println("Welcome to Itronic");

  // start the Ethernet connection:
#if defined(WIZ550io_WITH_MACADDRESS)
  if (Ethernet.begin() == 0) {
#else
  if (Ethernet.begin(mac) == 0) {
#endif
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    for (;;)
      ;
  }
  // print your local IP address:
  Serial.print("My IP address: ");
  for (byte thisByte = 0; thisByte < 4; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(Ethernet.localIP()[thisByte], DEC);
    Serial.print(".");
  }
  Serial.print("My MacAddress: ");
  for (byte thisByte = 0; thisByte < 6; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(mac[thisByte], HEX);
    Serial.print(",");
  }
  Serial.println();
  server.begin();
  // Hardware Serial (2,3) begin
  mySerial.begin(19200);
Serial.print("hostName: ");
  Serial.print(Ethernet.hostName());
      Serial.print("dnsDomainName: ");
  Serial.print(Ethernet.dnsDomainName());
  IRreceiver.enableIRIn();  // Start the receiver
}


texts: How to set cables to connect Cp2102 to Pro Mini?

texts:
How to connect the cables in order to program the pro mini with the CP2102 usb interface ?
The TX RX and GND is easy, but I am not sure about the RST, DTR, DST, etc
I attached the images of both.

EDIT: When I try cables like this:

TX  ... RX
RX  ... TX
5V  ... VCC // my pro mini is 5V version
GND ... GND
RST ... RST

The board lits up and green starts blinking, this should be the default blinker program.
I click upload, I get this error, and I assume the cables are not properly connected:

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x89
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x89

I know some people mentioned it works by adding some resistor and capacitor, but I was hoping that is an error and it should work without that complication.


texts: How do you make an Arduino count down timer?

texts:
I want to make a countdown timer with a LilyPad Arduino for 3 seconds with red (1 second), then orange(1 second), then yellow (1 second), then green (3 seconds), all being triggered by a button. I want to check to see if I have the right code. I am a self taught programmer, so apologies if this is a little messy. (or a lot)

#include <Adafruit_NeoPixel.h>
const int inputPin = 3;

void setup() {
  // put your setup code here, to run once:
  pinMode(inputPin, INPUT_PULLUP);
  strip.begin();
  strip.show();
}

void loop() {
  // put your main code here, to run repeatedly:
  If (digitalRead (inputPin) == LOW) {
    For (int i = 0; i < 12; I++) {
      Int pixelNum1 = 1;
      strip.setPixelColor( pixelNum1, 244, 0, 0);
      strip.show();
      delay (27);
      pixelNum1 ++;
    }

    For (int i = 0; i < 24; I++) {
      Int pixelNum2 = 1;
      strip.setPixelColor( pixelNum, 247, 247, 0)
      strip.show();
      delay (27);
      pixelNum ++;
    }

    For (int i = 0; i < 12; I++) {
      Int pixelNum3 = 1;
      strip.setPixelColor( pixelNum, 0, 247, 41)
      strip.show();
      delay (27);
      pixelNum ++;
    }
  }
}


texts: SoftwareSerial runs out of "text" space on ATtiny

texts:
I have an ATtiny and am trying to send a very large byte array stored in a separate .h file over SoftwareSerial:

for (int i=0; i<numElements; i++) {
    softSerial.println(myList[i]);
}

I imagine it will very slow, which is fine, but I'm getting a cryptic error when compiling:

Firmware.ino.elf section `.data' will not fit in region `text'

It seems that this is due to the println() command running out of memory for some reason – if I comment out the println() command everything works fine. How to fix this?


texts: Connecting esp8266 to spi/i2c video doorbell pins

texts:
The Vimar k40910 video doorbell exposes the following pins on its board:

vin (5v)
gnd
sda
scl
clk
data

As far as I understand, pin 3-4 are for I2c while 5-6 are for SPI.
Is there a way to connect to them (3-4 OR 5-6) and try to read something?
I would like to check if the doorbell output useful information throught these channels.
I have used I2c beforce, but to interfacing with an LCD display (sending commands, actually).
What is the best approach to connect in a safe mode to preserve the doorbell? Is it even possible?
I would like to connect an ESP8266, but I could use an ESP32 too.


texts: How to burn the bootloader onto a bare chip without using an Arduino board

texts:
How do I burn the UNO bootloader onto ATMEGA328P-PU without using an Arduino Uno board. That is burn directly from my PC or Android device??

I've tried nothing, I don't know a thing about microcontrollers ☺


texts: Cannot enter programming mode on Arduino Uno

texts:
I have an Arduino Uno that I've been programming with an AVR Dragon through Atmel Studio 7.

I did two things in close proximity, and I'm not entire sure which action is the culprit. I tried using the DebugWIRE interface (for the first time) instead of ISP in the tool select screen. I also hit the Arduino's reset button as Atmel Studio was compiling/uploading to the Arduino (stupid, I know.)

Now I cannot program with ISP the normal way, or do anything really.  If I try to upload to the Arduino I get:

I've tried to use the device programming feature using the Dragon and change the fuses as I've read about in other posts and get:

I've tried burning a new bootloader with the Arduino IDE and the IDE tries ten times, but it tells me that the programmer is not responding.

When I plug my AVR ISP mk2 into a different Arduino Uno I get a nice constant green light. If I plug it into the board I've been discussing it blinks red.

I'm not sure where to go from here...


texts:
I am using the Ethernet Shield on top of the Arduino Uno. I want to use this setup to access  webpages. But I am unable to access because the ethernet connection is present in a University which requires a proxy server with authentication. I am unsure of what extra code to include so as to get past the proxy which requires authentication.
Can anyone help in solving this problem?


texts: How to Work Two Linear Actuator Synchronously by Using Arduino and VNH5019 Motor Driver?

texts: I am newbie and I want to build a project that contains two linear actuator that move synchronously. Two of them will lift up and down at same time. I use arduino mega and VNH5019 motor driver. I have thompson electrac ELD linear actuator. I have never tried to synchronize two linear actuator. Linear actuator have encoder output ( it is hall effect encoder -( not absolute. So it cannot keep last position in case of power cut )). Encoder type is hall effect type. Encoder output voltage levels low (logical zero), typical / max is 0.1/0.25 Vdc. Also it has output fully extented/retracted signal. I tested it with H-Bridge motor driver made of 4 SSR relays and push button switches to retract and extract. There is a synchronization problem.The system will stop when actuators extracted 500 mm ( actuators have 900 mm stroke length) How should I solve that synchronozation problem could you help me ? What should I do?


texts:
Arduino: 1.8.14 (Windows Store 1.8.45.0) (Windows 10), Board: "Arduino Uno"

In file included from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.45.0_x86__mdqgnx93n4wtt\libraries\Servo\src/Servo.h:63:0,

                 from C:\Users\Msi\Documents\Arduino\final_dost\final_dost.ino:7:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.45.0_x86__mdqgnx93n4wtt\libraries\Servo\src/avr/ServoTimers.h:57:1: error: expected initializer before 'typedef'

 typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t;

 ^~~~~~~

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.45.0_x86__mdqgnx93n4wtt\libraries\Servo\src/avr/ServoTimers.h:57:41: error: 'timer16_Sequence_t' does not name a type

 typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t;

                                         ^~~~~~~~~~~~~~~~~~

Multiple libraries were found for "AFMotor.h"

 Used: C:\Users\Msi\Documents\Arduino\libraries\adafruit-Adafruit-Motor-Shield-library-d815040

 Not used: C:\Users\Msi\Documents\Arduino\libraries\Adafruit-Motor-Shield-library-master

exit status 1

Error compiling for board Arduino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


texts: The Arduino IDE can’t find my Arduino Uno

texts: My Arduino has all of its LEDs on. The Rx, Tx and L LEDs are all on and my computer can’t see it (it's an SMD edition).


texts: My ArI was using a potentiometer and the system shorted maybe. Do I have to replace the USB interface chip? It doesn't reset also

texts: See I was using a micro analog rotary potentiometer to control a servo. The pot was in a pcb. The 5v output and gnd were connected to arduino from the pot. The third pin and 5v got touched and it got fused. The Rx and TX led glowed constantly till I disconnected the 12v input.


texts: communication between python and arduino

texts:
I have a python program that calculates an integer based on some parameters. I am not including the full code here because because it has a lot of deep learning stuff , but the relevant block is:
#calculating time
def gst(no_signals,numbers): #car bus motorcycle truck
    time= [4,2,3.5,3.5]
    x=0
    for i in range(0,4):
        x+=numbers[i]*time[i]
    gst= int (x/(no_signals +1))
    print(gst)
    return(gst)

Now I want to communicate this gst which I have calculated to an Arduino program that is supposed to control the delays for the leds by an amount gst seconds.
The Arduino circuit and code currently look like:

(note that this picture may show some resistors to be unconnected to the breadboard properly. I have fixed that)
code
(the working of the code is explained in detail in this question:LED not lighting up despite digitalRead displaying 1)
int gst=20; //green signal time initialised to 20
int ns=4;  //no.of signals
int sn=1; //current signal number

//pin numbers for LEDS: {{RYG for signal1},{RYG forr signal2}..}
int signal[4][3]={{2,3,4},{5,6,7},{8,9,10},{11,12,13}};

//indexes for the signal array
int red=0;
int yellow=1;
int green=2;

//pin number of "colour" of signal "i" is given by signal[i][colour]
//example: red led of signal 3: signal[2][0]

void setup()
{
  for(int i=2;i<=13;i++){
    pinMode(i,OUTPUT);
  }
  Serial.begin(9600);
  randomSeed(analogRead(0));
}

void loop()
{
    int next_sn= sn+1; //next signal
    if(next_sn==5)
      next_sn=1;

    int next2_sn= next_sn+1; //next2next
    if(next2_sn==5)
      next2_sn=1;

    int next3_sn= next2_sn+1; //next2next2next
     if(next3_sn==5)
      next3_sn=1;

   //current signal green (for gst seconds), rest all red.

    digitalWrite(signal[sn-1][green],HIGH);
    digitalWrite(signal[sn-1][red],LOW); //this line will make sense
                                      //for the 2nd iteration

    digitalWrite(signal[next_sn-1][red],HIGH);
    digitalWrite(signal[next2_sn-1][red],HIGH);
    digitalWrite(signal[next3_sn-1][red],HIGH);

    //for debugging purposes

    Serial.println(digitalRead(signal[sn-1][green]));

    delay(gst*1000);

    //gst seconds elapsed, now current signal should become yellow

    digitalWrite(signal[sn-1][green],LOW);
    digitalWrite(signal[sn-1][yellow],HIGH);

    delay(5*1000);

    //snapshot taken for calculating no. of cars, buses etc
    //for now, random numbers used
    //we will need to integrate this block with YOLO.

     //calculate gst

     gst=random(10,20);

  //make current signal red

    digitalWrite(signal[sn-1][red],HIGH);
    digitalWrite(signal[sn-1][yellow],LOW);

  //the next signal is our current signal for the next iteration
  //the green signal should turns on for gst seconds in the next
  //iteration,and the red signal turns off
    sn=next_sn;

  }

Currently, I am using gst=random(10,20);for updating gst. I want to eventually write something like gst=<gst communicated from python>; in place of this.
How can I achieve this?
There's also a second problem: The Arduino program and code run on a simulation website (tinkercad). So I am a bit confused with how exactly we can enable communication. Normally, you stick a USB cable to do that but I obviously cant do that since the arduino is on a simulation website.
simulation link: https://www.tinkercad.com/things/4TzYWouocTv
How can I proceed further?


texts:
I'm trying to determine what is the best way to scale a magnometer to a servo, I am using the BNO055 from Bosch I get a heading say 50 degrees, and I want to be able to input 45 degrees and have the servo motor move accordingly. I am using a 180 degree motor. I would like to be able to input 45 degrees, and then the motor if 50 degrees was 95, would decrease in value step by step until the magnometer read 45; I'm having difficulty creating the logic to do this.

Bosch output is between 0 and 360; so I could end up with servo 0 is 120; and servo 180 is 300. Meaning the values are 300 - 360, 0 - 120 making the full 180, so I am not sure how I could use something like map in arduino to solve this issue.


texts: NRF24 - get a null error while module moves

texts:
I'm using 2 NRF24L01 modules As this to send and receive data. Both are connected using a adapter as this.
One is connected to a Nano and the other to a Wemos. I'm using nRF24L01 library for my code.
Code is running as Expected, but from time to time, when moving around the NRF24L01 connected to the Nano (or the other one connected to the Wemos) while code is running causing it to spit a long series of null's and from now on it only Tx messages and not Rx. Of course all DuPont wires were changed several times in new ones to exclude bad wires. Since it can happen from time to time, and in some cases it happens after several good shakes, I want my system will know how to deal with such cases (identify and react) rather than - Avoid shaking it.
I know that radio.begin() solves this (for that it used the test isChipConnected() to identify that the chip was pulled out, in my case - in purpose), and system was back to Tx and Rx as expected.
I'm wondering what may identify that state, in order to call radio.begin() or other workaround.
Example: Output shows
a) State before shaking NRF24L01 module.
b) null's due to that shake.
c) All messages are sent and received OK, but no incoming messages ( and on the other side, sent messages failed ).
14:54:22.444 -> <<[incoming] {"from":"Wemos","type":"ans","key0":"clk","key2":"2021-05-15 14:54:22"}
14:54:23.272 -> >>[outgoing] {"from":"Arduino","type":"q","key0":"clk"}
14:54:23.305 -> <<[incoming] {"from":"Wemos","type":"ans","key0":"clk","key2":"2021-05-15 14:54:22"}
14:54:23.371 -> nullnullnullnullnullnullnullnullnullnullnullnullnullnull>>[outgoing] {"from":"Arduino","type":"q","key0":"clk"}
14:54:24.927 -> >>[outgoing] {"from":"Arduino","type":"q","key0":"clk"}
14:54:25.722 -> >>[outgoing] {"from":"Arduino","type":"q","key0":"clk"}
14:54:26.516 -> >>[outgoing] {"from":"Arduino","type":"q","key0":"clk"}
14:54:27.344 -> >>[outgoing] {"from":"Arduino","type":"q","key0":"clk"}
14:54:28.139 -> >>[outgoing] {"from":"Arduino","type":"q","key0":"clk"}
14:54:28.934 -> >>[outgoing] {"from":"Arduino","type":"q","key0":"clk"}
14:54:29.762 -> >>[outgoing] {"from":"Arduino","type":"q","key0":"clk"}
14:54:30.557 -> >>[outgoing] {"from":"Arduino","type":"q","key0":"clk"}


texts: What is the difference when an arduino has been unplugged vs when a serial port connection was closed?

texts:
Using python code for a serial port connection to an arduino, it sends a value to the arduino, which then starts printing values to serial. The python code will print the value on the first or second run (if run soon enough after), but after that it won't read what's from Serial.println again. To get it to read again (whether I wait some time or not, like for the while loop to finish), the arduino has to be unplugged and plugged in again, why is that different than the serial port connection being closed by python? Here is the arduino code used,
int measured;
int counter = 0;
int maxnum = 10;

void setup()
{
Serial.begin(9600);
}

void loop()
{
  if(Serial.available() > 0)
  {
    while(counter < maxnum)
    {

        Serial.println("V");
        counter++;
        delay(100);

    }
  }
}

I know the value sent from python can be read because I added in code that reads from serial after checking if it's available and changed an output pin value, which works, even if the serial println is not read.
Edit: Since the answer is there shouldn't be a significant difference and the arduino script should be reset if the serial port was closed, the issue should be with the python code.


texts: Combining two sketches that both work on their own, but don't work when combined

texts:
I've got a program for a password protected doorlock, which I got working.

I'm trying to add to the code, to add functionality where I can toggle an LED on/off with a button.

Both codes function on their own and serve their desired purpose, but when I try to combine them into the same sketch, the LED button works but the rest of my design stops working. I can no longer input a password to activate the motor.

How can I combine the two codes and have them both work?

Here is the working keypad/lock code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>

#define Password_Length 5

int signalPin = 10;
int greenLedPin = 11;
int redLedPin = 12;
char Data[Password_Length] = "4";
char Master[Password_Length] = "1234";
byte data_count = 0, master_count = 0;
bool Pass_is_good;
char customKey;

const byte ROWS = 4;
const byte COLS = 3;
bool ledState = 0;

char hexaKeys[ROWS][COLS] = {
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};

byte rowPins[ROWS] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3};

Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS,     COLS);

LiquidCrystal_I2C lcd(0x3f, 16, 2);

void setup()
{
  lcd.init();
  lcd.backlight();
  Serial.begin(9600);
  lcd.clear();

  pinMode(redLedPin, OUTPUT);
  pinMode(greenLedPin, OUTPUT);
  digitalWrite(redLedPin, LOW);
  digitalWrite(greenLedPin, LOW);
}

void loop()
{
  lcd.setCursor(0,0);
  lcd.print("Enter Password:");

  customKey = customKeypad.getKey();
  if (customKey){
    Data[data_count] = customKey;
    lcd.setCursor(data_count,1);
    lcd.print(Data[data_count]);
    data_count++;
    }

if(data_count == Password_Length-1){
    lcd.clear();

    if(!strcmp(Data, Master)){
      lcd.print("Correct");
      pinMode(signalPin, OUTPUT);
      digitalWrite(signalPin, LOW); //turns on motor
      digitalWrite(greenLedPin, HIGH); //turns on led
      delay(2000);
      digitalWrite(signalPin, HIGH); //turns off motor
      digitalWrite(greenLedPin, LOW); //turns off led
      }
    else{
      lcd.print("Incorrect");
      digitalWrite(redLedPin, HIGH); //turns on led
      delay(2000);
      digitalWrite(redLedPin, LOW); //turns off led
      }

    lcd.clear();
    clearData();
  }
}

void clearData(){
  while(data_count !=0){
    Data[data_count--] = 0;
  }
  return;
}

and here is the code I'm using for the LED on/off toggle button

int button = 2;
int led = 13;
int status = false;

void setup(){
pinMode(led, OUTPUT);
pinMode(button, INPUT_PULLUP); // set the internal pull up resistor,
unpressed button is HIGH
}

void loop()
{
//a) if the button is not pressed the false status is reversed by !status
and the LED turns on
//b) if the button is pressed the true status is reversed by !status and
the LED turns off

if (digitalRead(button) == true) {
status = !status;
digitalWrite(led, status);
} while(digitalRead(button) == true);
delay(50); // keeps a small delay
}


texts: error: expected primary-expression before ',' token edit status 1

texts:
Im using tinkercad for my robotics class and I can't seem to figure out a solution for this problem.
Heres my codes:
#include <LiquidCrystal.h> //LCD library
#define echo 2
#define trig 3

// Gas Sensor
#define GREEN 4
#define Yellow 6
#define RED 7
#define Buzzer 5
#define Sensor A0

float duration;
float distance;

LiquidCrystal lcd(13,,12,11,10,9,8);

int sensor_Input;
float temp;

void setup()
{
  // Ultrasonic sensor
  pinMode(trig, OUTPUT);
  pinMode(echo, INPUT);
  Serial.begin(9600);
  lcd.begin(13, 2);

  //temp
  measure_Temp();
  display_Temp();

  // Gas Sensor
  for (int i = 0; i < 6; i++)
    pinMode(i, OUTPUT);
  Serial.begin(9600);
}

void loop()
{
  // Ultrasonic Sensor
  time_Measurement();
  distance = duration * (0.0343) /2;

  display_distance();

  // Gas Sensor
  for (int i = 0; i < 6; i++)
    digitalWrite(i, LOW);

  status_Indicator();
}

void status_Indicator()
{
  // Gas Sensor
  int sensor_In = analogRead(A0);
  Serial.println(sensor_In);

  if ( sensor_In>=40 )
  {
    digitalWrite(RED, HIGH);
    digitalWrite(Buzzer, HIGH);
  }
  else if (sensor_In >=25 )
  {
    digitalWrite(Yellow, HIGH);
  }
  else
  {
    digitalWrite(GREEN, HIGH);
  }
  delay(10);
}

void time_Measurement()
{
  // Ultrasonic Sensor
  digitalWrite(trig, LOW);
  delayMicroseconds(2);

  digitalWrite(trig, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig, LOW);

  duration = pulseIn(echo, HIGH);
}

void display_distance()
{
  lcd.clear();
    lcd.setCursor(0, 0);
  Serial.print("Distance in m: ");
  Serial.print(distance);
  Serial.println();
  lcd.print("distance in m: ");
  lcd.setCursor(5, 1);
  lcd.print(distance);
  delay(1000);
}

void measure_Temp()
{
  //Temp
  sensor_Input = analogRead(A0);
  temp = (float)sensor_Input / 1024;
  temp = temp *5;
  temp = temp - 0.5;
  temp = temp *100;
}

void display_Temp()
{
  //temp
  lcd.setCursor(0, 0);
  Serial.print("Temp. in Celcius: ");
  Serial.print(temp);
  Serial.println();
  lcd.print("Temp. in Celcius: ");
  lcd.setCursor(5, 1);
  lcd.print(temp);
  delay(500);
}


texts:
I'm experimenting with the joystick and the MAX7219 module (8x8 LED display) and i made this program:
#include "LedControl.h"

LedControl lc=LedControl(11,13,10,1);

int Xo = 36;
int Yo = 34;

int xPin = A1;
int yPin = A0;
int buttonPin = 7;

int xPos = 0;
int yPos = 0;

int Xvel = 0;
int Yvel = 0;

int lastMapX = -1;
int lastMapY = 0;

void setup() {
  pinMode(xPin, INPUT);
  pinMode(yPin, INPUT);
  pinMode(buttonPin, INPUT_PULLUP);
  Serial.begin(9600);
  lc.shutdown(0,false);
  lc.setIntensity(0,8);
  lc.clearDisplay(0);
}

void loop() {

  Xvel = joystickMap(xPin, Xo);
  Yvel = joystickMap(yPin, Yo);

  if (Xvel == 0 and Yvel == 0) {
    Xvel = lastMapX;
    Yvel = lastMapY;
  }

  yPos = yPos + Xvel;
  xPos = xPos + Yvel;

  if (xPos < 0) {
    xPos = 0;
  }else if (yPos < 0) {
    yPos = 0;
  }else if (xPos > 7) {
    xPos = 7;
  }else if (yPos > 7) {
    yPos = 7;
  }

  lc.clearDisplay(0);
  lc.setLed(0,xPos,yPos,true);

  Serial.print("x=");
  Serial.print(yPos);
  Serial.print(" y=");
  Serial.print(xPos);
  Serial.print(" buttonpress=");
  Serial.print(digitalRead(7)==0);
  Serial.print(" x>7=");
  Serial.println(xPos > 7);

  lastMapX = Xvel;
  lastMapY = Yvel;

  delay(100);
}

int joystickMap(int in, long offset) {
  int firMap = map(analogRead(in), 0, 1023, -102, 100)+offset;
  if (firMap == 0 or firMap == 1 or firMap == -1) {
    return 0;
  }else if (firMap > 0) {
    return 1;
  }else if (firMap < 0) {
    return -1;
  }
}

it should make it for the player impossible to stop. But there is a glitch witch allows you to go off-screen. If you are in any corner and you go diagonally to the opposite corner you just go through. Here  is a screenshot with the program and the serial monitor:

My Arduino is a UNO R3. How can i fix this glitch?


texts:
Trying to power the board with a 9V battery through VIN. As the documentation says, it can take input voltage of 6-12 Volts, but when I connect the 9V battery, all it does is power the board on and nothing else happens.

Anyone know what I am doing wrong?

EDIT: I am stupid had the ground connected to the wrong pin thanks for the help everyone.


texts: getting overflow on number of steps . used uno originally went to mega and still have overflow issues

texts:
using DM860T driver set at 800 steps. anything as high as 40 revolutions causes overflow. any idea of problem and how to fix?
set steps per revolution to 800, and multiplied revolutions times steps (40800). works fine
reset revolutions to an extra 20 (60800) and instead of getting more revolutions got less.
presume it reset to zero.
thought with the mega I would not have problem, but seems to be same as with uno


texts:
I have two devices. Sensor for temperature and humidity and lcd screen. Both require SDA pin, and I have only one on my arduino.

I want my display to show current temperature but I don't know how to connect two things on one pin.

Can I somehow read from other pins maybe?

Also, what can I do if I have only 1 5V source and I have two devices that require 5V?

My arduino model is Arduino Mega 2560 R3

I have this aosong sensor (AM2301), and I have YwRobots 2 row LCD screen which I want to connect to my board along with sensor.

So... I'm not sure how to connect those two if both require SDA and I have only one.


texts: How do I avoid this error trying to connect arduino to pc with linux fedora 20

texts:
I used Arduino successfully on my old Linux Fedora 12 system. Now I have a brand new PC with Fedora 20, and have today installed Arduino on it. In my first attempt to use it I typed Arduino as follows at the root prompt, after the "yum install arduino" gave me "Complete!", as follows:

Complete!
[1344][root@localhost:/home/Harry]# arduino
WARNING:  RXTX Version mismatch
    Jar version = RXTX-2.2
    native lib Version = RXTX-2.2pre2

Subsequently I have loaded the "Blink" sketch, and that is running nicely, whether I start the IDE from the command line, which still gives me the same WARNING, or from the desktop icon, which does not give it.

So my question is: please, does this WARNING matter? If so, what should I do about it?


texts:
I know that in C++, to include a library, you either put the library name in <x> or "x". Now, I believe that this was because of a major change in the C++ language a some time ago.

Now, in Arduino, there are 2 types of Wire (I2C) library : <Wire.h> and "Wire.h".

Which one is the right one?

I've seem people using both, and they both seem to work.


texts: How to send data to multiple slave at a time

texts: I have one master and three slave devices and i need to send data to all the slaves at a time.is that possible if so how to check which slave has recieved the data first


texts: Why UDP does not work after analogRead() on esp8266-12N module?

texts:
Consider my loop() in Arduino be:

void loop(){
  for(int i = 0; i<100; i++){
   Value[i] = analogRead(A0);
   delayMicroseconds(62);
  }
   //delay(2) //when I use this line esp8266 works properly
   Udp.beginPacket(IP, Port);
   Udp.write(Value, 100);
   Udp.endPacket();
}

after analogRead() UDP can't send packets and crash occur after a moment. But when I use delay(2) line in the above code it works properly. I want to record samples of microphone with 16000 sample rate and I use 62 microseconds for this. Thus in my application it is not possible for delay 2 milliseconds. How can I fix this without delay?


texts:
Just picked up a couple of 74HC595 shift registers to use for my Arduino Uno, and I'm having trouble getting it working 100% of the time. My code is to get a value from the Serial monitor and shift it into the register. The issue is that bits 4 and 5 are always on no matter what I put into the monitor, but when I clock a 0 into the register during setup(), it works as expected, i.e. all LEDs go off

Here is the code:

int dataPin = 2;
int latchPin = 3;
int clockPin = 4;

void setup() {
    Serial.begin(9600);
    pinMode(dataPin, OUTPUT);
    pinMode(latchPin, OUTPUT);
    pinMode(clockPin, OUTPUT);

    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, 0);
    digitalWrite(latchPin, HIGH);
}

void loop() {
    if(Serial.available()) {
        digitalWrite(latchPin, LOW);
        shiftOut(dataPin, clockPin, MSBFIRST, Serial.read());
        digitalWrite(latchPin, HIGH);
    }
}

Is it the code that is wrong? Do i have a busted shift register? Or something else?
Thanks


texts: MB-102 BreadBoard Power Supply Limitation

texts:
Does the MB-102 can handle Arduino Uno, SIM900 and 3 other modules that requires 5v? If yes, does 9v battery is enough? If no, please suggest me what should I use that uses only 1 barrel jack(if possible).

Im afraid that I might fry it if I try cause I dont have enough knowledge about electric currents.


texts: LED PowerSuply problem Arduino light installation

texts: I want to have 40 or more of these led's in a light instalation. What power suply or components hould i use?Shoul i conect the Leds in series ou parallel? I will control the led's using mosfets conected to arduino, and control IT using MAX MASP over OSC.


texts:
I have NodeMCU ESP8266N Lolin V3, my 5V relay is powered from Vin of the NodeMCU.
The NodeMCU is powered from 5V USB.

My difficulty is when I measure voltage between Vin & GND, it is of 1.9V, but supposed to be around 5V as it is directly attached with usb 5V supply. Actually my relay is not working with the power tapped from Vin, but relay's led & NodeMCU  led are blinking but relay coil does not trip.
Please confirm is my NodeMCU having problems as voltage between vin & GND read 1.9V.
https://drive.google.com/file/d/1Z6jYX4sCLmRxnWbtBYZCNW6LpckokaC9/view?usp=drivesdk


texts: Arduino IDE documentation for WiFi.connected()

texts:
I'm including this library "ESP8266WiFi.h" at the top of my sketch.
I can find documentation on WiFiServer.available(), but didn't find for WiFi.connected(), which is called in a server sketch after getting the client.

Clearly it's a test whether (once? I believe) the client is connected or not (and hasn't been explicitly closed in the server's side). It may seem obvious but some documented info would be helpful though.


texts: Breaking out of a while loop using IR remote for neopixel

texts:
I've been piecing together various lighting effects. I am wanting to have each lighting effect loop until another button is pressed to trigger another lighting effect.

I've come to a bit of standstill at the moment. I've created a loop that doesn't seem to end. I've had a look around but I can't work out how to fix my code. Sorry in advanced, I'm new to using arduinos but if anyone could help out, it would be much appreciated.
Thanks!

//www.elegoo.com
//2016.12.9

#include "IRremote.h"
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 6

Adafruit_NeoPixel strip = Adafruit_NeoPixel(20, PIN, NEO_GRB + NEO_KHZ800);

int receiver = 11; // Signal Pin of IR receiver to Arduino Digital Pin 11

/*-----( Declare objects )-----*/
IRrecv irrecv(receiver);     // create instance of 'irrecv'
decode_results results;      // create instance of 'decode_results'
int Remote = 0;

/*-----( Function )-----*/
void translateIR() // takes action based on IR code received

// describing Remote IR codes

{

  switch(results.value)

  {
  case 0xFFA25D: Serial.println("POWER");
  ArrowRight(strip.Color(25, 0, 0), 100); //Red
  ArrowRight(strip.Color(0, 0, 25), 100); //Blue
//  Remote = 0xFFA25D;
  break;

  case 0xFFE21D: Serial.println("FUNC/STOP");
  ArrowLeft(strip.Color(25, 0, 0), 100); // Red
  ArrowLeft(strip.Color(0, 0, 25), 100); // Blue
//  Remote = 0xFFE21D;
  break;

  case 0xFF629D: Serial.println("VOL+"); break;
  case 0xFF22DD: Serial.println("FAST BACK");    break;
  case 0xFF02FD: Serial.println("PAUSE");    break;
  case 0xFFC23D: Serial.println("FAST FORWARD");   break;
  case 0xFFE01F: Serial.println("DOWN");    break;
  case 0xFFA857: Serial.println("VOL-");    break;
  case 0xFF906F: Serial.println("UP");    break;
  case 0xFF9867: Serial.println("EQ");    break;
  case 0xFFB04F: Serial.println("ST/REPT");    break;
  case 0xFF6897: Serial.println("0");    break;
  case 0xFF30CF: Serial.println("1");    break;
  case 0xFF18E7: Serial.println("2");    break;
  case 0xFF7A85: Serial.println("3");    break;
  case 0xFF10EF: Serial.println("4");    break;
  case 0xFF38C7: Serial.println("5");    break;
  case 0xFF5AA5: Serial.println("6");    break;
  case 0xFF42BD: Serial.println("7");    break;
  case 0xFF4AB5: Serial.println("8");    break;
  case 0xFF52AD: Serial.println("9");    break;
  case 0xFFFFFFFF: Serial.println(" REPEAT");break;

  default:
    Serial.println(" other button   ");

  }// End Case

  delay(0); // Do not get immediate repeat

} //END translateIR
void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  Serial.begin(9600);
  Serial.println("IR Receiver Button Decode");
  irrecv.enableIRIn(); // Start the receiver
  strip.begin();
  strip.show();
  Remote = 0;

}/*--(end setup )---*/

void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
  if (irrecv.decode(&results)) // have we received an IR signal?

  {
    translateIR();
    irrecv.resume(); // receive the next value
  }
}/* --(end main loop )-- */

void ArrowRight(uint32_t c, uint8_t wait) {
  while (Remote = 0xFFA25D) {
    for (uint16_t i = strip.numPixels()/2; i < strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
    }
    for (uint16_t i = 0; i < strip.numPixels(); i++) {
      strip.setPixelColor(i, 0);
    }
    strip.show();
    delay(wait);
  }
}

void ArrowLeft(uint32_t c, uint8_t wait) {
  while (Remote = 0xFFE21D) { // The j<# determines how many cycles
    for (uint16_t i = strip.numPixels()/2-1; i + 1 > 0 ; i--) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
    }
    for (uint16_t i = strip.numPixels(); i + 1 > 0 ; i--) {
      strip.setPixelColor(i, 0);
    }
    strip.show();
    delay(wait);
  }
}


texts: Using ALL the analog pins on Mega for Servo

texts: I wish to use ALL the Analog pins on a Mega2560 R3 to control Servo's, all is well up to and including A9, but from there on nothing. {sound familiar} this is apparently not a new problem. I have tried Servo.h and MegaServo.h but still no luck, does anyone have info on a library that will do this or a method to get around it........all the pins on the end buss are used for other purposes and are not available. I can post the code, but first just asking the general questions. Thanks Doug


texts: Use an Arduino as a user interface for the computer

texts:
I wanted to use either Arduino Mega or Uno as a form of an interface between me and the computer. I want to apply it to the following scenario; if I press a button on a circuit board I want it to trigger an action on my computer, like scroll down.

How can I achieve this? How would the code look like and what programs would I need to translate from Arduino to Windows?


texts: Movement and storage of servo positions via bluetooth

texts:
I am trying to program a 4DOF robotic arm (using 4 servo motors). I would like to move the servos using an Android app, by means of bluetooth (HC-05).
I developed the app, in whose interface there are 7 buttons (Up, Down, Left, Rght, Forward, Backward, Save) and a field in which you can type using the keyboard (I attached an app interface screenshot).
So far, I tried to manage only Up button (which senses 'U' via bluetooth to Arduino) and Down (which sens 'D'), which would move the servo intended for vertical arm movements. That code works quite well, although the app crashes sometimes, but I still can't figure the reason out. Using the println() function I can see that Arduino reads in the bluetooth input the character '⸮ ' , what does it mean? I use a baud rate of 9600.
Then, what I would like to do is: once I have moved the servo and reached a particular position, I'd like to save the position of the motor into an array. In order to allow multiple positions saving, after Save button is pressed, I want Arduino to wait for another input from the bluetooth (so that, it would wait for another button to be clicked from the app or for something typed into the dedicated bar from keyboard) that defines the position within the array, in which I save the servo position (eg: I type '2' into the dedicated app bar and Arduino, which is waiting for an input, receiving it, saves the last servo position into the array servo01pos[2]). I wrote the "case ('S')" code that is quite long and inefficient but, at least, it works.
Thanks in advance to anyone who will help me.
Giammarco

#include <SoftwareSerial.h>
SoftwareSerial bluetooth(10, 11); //BlueTooth RX ,TX
#include <Servo.h> // servo library

unsigned long timestampSend = 0; // BT Write wait period
String readString;
Servo servo01; // servo name
byte pos01 = 90;
#define ANGLE_STEP 10 // 10 degree steps
int servo01pos\[50\];
char data;
char button;
int x = 1;

void setup() {
  Serial.begin(9600);
  bluetooth.begin(9600);
  delay(1000);
  Serial.println("Ready ...");
  Serial.println ("\n");
  servo01.attach(12);
  servo01.write(pos01);
}

void loop() {
  do {
    if (bluetooth.available() > 0) {
      Serial.println(data);
      do {
        delay(500);
        data = bluetooth.read();
        Serial.println(data);
      } while (bluetooth.available() > 0);
      if (data == 'U' || data == 'D' || data == 'L' || data == 'R' || data == 'F' || data == 'B' || data == 'S' || data == 'X') {
        Serial.print("Received value: ");
        Serial.println(data);
        switch (data) {
          case ('S'): //SAVE
            Serial.println("Enter the button you desire to set...");
            do {
              data = 254;
              bluetooth.listen();
              button = bluetooth.read();
              if (button == '0' || button == '1' || button == '2') {
                data = 'S';
              }
            } while (data != 'S');
            Serial.println("SAVING POSITIONS ...");
            if (button == '0') {
              servo01pos\[0\] = pos01;
            } else if (button == '1') {
              servo01pos\[1\] = pos01;
            } else if (button == '2') {
              servo01pos\[2\] = pos01;
            }
            servo01.write(pos01);
            Serial.println(button);
            Serial.println(pos01);
            Serial.println(servo01pos\[1\]);
            Serial.println(servo01pos\[2\]);
            Serial.println(servo01pos\[0\]);
            //}
            break;

          case ('U'):
            Serial.println("UP");
            if (pos01 <= 180 - ANGLE_STEP) {
              pos01 = pos01 + ANGLE_STEP;
              servo01.write(pos01);
              Serial.println(pos01);
              delay(20);
              Serial.println(data);
            }
            break;

          case ('X'):
            Serial.println("EXIT");
            x = 0;
            break;
        }
      }
    }
  } while (x != 0) ;
}


texts:
Hi my lcd doesnt display that i was expected. Can anyone help me???

RS-->22
RW-->GROUND
E-->23
D4-->24
D5-->25
D6-->26
D7-->27

    #include <LiquidCrystal.h>

LiquidCrystal lcd(22, 23, 24, 25, 26, 27);
void setup() {

lcd.begin(16,2);

lcd.setCursor(0,1);
lcd.print("Hello!");
delay(1000);
}
void loop() {
lcd.setCursor(0,1);
lcd.print(millis()/1000);
}


texts: ATtiny85 MIDI IN with less than 3V -can it be done?

texts:
I've been trying to add a MIDI INput to an ATtiny-based synthesizer, powered by a CR2032 battery (3v) and running softwareSerial.

Currently I'm using an H11L1 optocoupler, which works fine at 5v, but I am missing notes at 3V; I'm not sure whether the problem is the optocoupler, or that the ATtiny can't establish proper communication on that voltage; any pointers will be much appreciated :)


texts: LCD on top of SD datalogger flickers help!

texts: I have a problem with my 16,2 with buttons lcd shield.(LCD Keypad Shield). It is connected on top of an SD dataloger. I came to the conclusion that every time the sd shield logs data and completes the loop it switches off and on,flickering the lcd, and moves on with the loop. Is there any way to stop the flickering while the sd shield logs??


texts: For one of my university projects I need to detect the presence of a person in the shower. In order to do that what I have in mind is use a proximity sensor. If the target is in a distance range (let's say 20 to 50 cm) It will assume that the person is in the shower when the distance measure is no longer in this range then it will mean that the person left the shower. I need to detect all the time of the person in the shower (meaning when he/she gets in and then out). I have read a lot of info and forums to properly choose the type of sensor. However I still don't have a clear answer. About the Ultrasonic proximity sensors I know that they are cheap and more accurate by it can be affected by Temperature, humidity and some ambient noise, all of them which happen in a shower. The other option an Infrared one gets affected by lightning conditions and the surface of the target. The last option I checked is a PIR sensor I know it senses Temperature of the target, but I don't know if it will be affected by the running hot water and also is more expensive. In general, I don't know how the running hot water will affect the detection of the person in shower. Also,so again I don't know how this will work. Sorry for the huge amount of  questions, I am a little bit confuse with all the factors to have in mind. I am hoping someone out there can help a lost newbie like me and give me a suggestion. Thanks a lot :)


texts: Mac Arduino IDE Connection to Min Seg (Mega 2560). No tty

texts:
I own a Macbook running OS X 10.10.3 (Yosemite)

I own a Min Seg.
My Min Seg model is built on an Arduino Mega 2560.

Problem

When I connect the board to the Macbook,
using either of the Macbook's two USB 2.0 ports,
using either of two USB A to B cables,
the board lights up, but I am unable to connect
to the tty device using the Arduino IDE.

Tools --> Port offered:

/dev/cu.Bluetooth-Incoming-Port
/dev/cu.Bluetooth-Modem
/dev/cu.usbmodem621 (Arduino Genuino Mega or Mega 2560)

I was expecting to also see:

/dev/tty.usbmodem621 (Arduino Genuino Mega or Mega 2560)

If I unplug the board, the third listed option
from Tools --> Port disappears, as expected.

Verification 1

I opened the System Information utility application.

USB --> USB Bus -->Arduino Mega:

  Product ID:    0x0042
  Vendor  ID:    0x2a03
  Version:       0.01
  Serial Number: 75435353038351316281
  Speed:         Up to 12 Mb/sec
  Manufacturer:  Arduino Srl
  Location ID:   0x06200000 / 3
  Current Available (mA): 500
  Current Required  (mA): 100

Verification 2

I used the Sparkfun Terminal Basics wiki to check for the device.
I used the Terminal utility application.

ls /dev/tty.* offered:

/dev/tty.Bluetooth-Incoming-Port
/dev/tty.Bluetooth-Modem
/dev/tty.usbmodem621

screen /dev/tty.usbmodem621 9600 offered a successful connection.
[A white screen, which allowed for exit using Control+A followed by Control+/]

Attempted Solutions

I tried several means from here:

I installed the FTDI drivers.
I ran sudo nvram boot-args="kext-dev-mode=1" in the Terminal application.
Is an alternative driver worth attempting, such as that listed here?

I also attempted to connect through Mathworks Simulink.
When setting connection options, the program states
that a cu device is expected, rather than a tty.


texts: keypad code is not working and produces wrong numbers

texts:
I have the following issues:

1) When i press for example number 7 on the keypad it shows a different number on the serial monitor
2) The servo motor works for any combination of 4 numbers.

Code:
/*http://openhwdesign.comLock system using a Keypad
*/

#include <Password.h>
#include <Keypad.h>
#include <Servo.h>
#pragma GCC diagnostic ignored "-Wwrite-strings"
Servo myservo; //declare servo
Password password = Password( "5523" );

const byte ROWS = 4; // declare the rows of the keypad
const byte COLS = 3; // declare the columns of the keypad

// Define the Keymap

char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};

byte rowPins[ROWS] = {2,3,4,5}; // Connect keypad’s pins to these Arduino pins.
byte colPins[COLS] = {6,7,8}; // Connect keypad’s pins to these Arduino pins.

// Create the KeyPad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
Serial.begin(9600);
myservo.write(0);
pinMode(11, OUTPUT); //The green led is set as an output.
pinMode(12, OUTPUT); //The red led is set as an output.
myservo.attach(13); //The servo is connected to the digital pin 13.
keypad.addEventListener(keypadEvent); //Add an event listener for the KeyPad

}

void loop(){
keypad.getKey();
myservo.write(180); //why? what happens if you comment it? ###########################
//delay(5);
}

void keypadEvent(KeypadEvent eKey){
// When the KeyPad will be pressed, the results will appear on the serial monitor.
switch (keypad.getState()){
case PRESSED:
Serial.print("Enter: ");
Serial.println(eKey);
delay(10);

switch (eKey){
case '*':
checkPassword(); // Will check the password.
delay(1); // Delay used for stability.
break;

case '#':
password.reset(); //Will reset the password
delay(1); // Delay used for stability.
break;

default:
password.append(eKey); //Append any keypress that is not a ‘#’ nor a ‘*’.
delay(1);
}
}
}
void checkPassword(){

if (password.evaluate()){ //If the combination inserted is equal to the combination saved, the servo’ll rotate.
Serial.println("Accepted");
//delay(5000);
delay(10);
myservo.write(50); //was 140
delay(5000);

digitalWrite(11, HIGH); //Turn the green led on.
delay(500); //Wait 5 seconds.
digitalWrite(11, LOW); //Turn the green led off.

//break; // remove if trial did not work #####################try#####################
}
//break; // remove if trial did not work ##########################################
else{ //If the combination inserted isn’t equal to the combination saved, the servo will not rotate.
//delay(5000); delays response
Serial.println("denied");
delay(10);
//delay(5000);
myservo.write(20); // was 50
digitalWrite(12, HIGH); //Turn the green led on.
delay(5000); //Wait 5 seconds. was 500 ///
digitalWrite(12, LOW); //Turn the green led off.

    }
}

Thank you.


texts: Need a component to connect a 9v water pump

texts:
I have a 9v water pump that i want to turn on\off from the arduino,
What module should i use to turn it on and off?

I am using now a mosfet for my 5v pump, can a mosfet be used for 9v as well? Or is there some better solution?


texts:
I wrote an Arduino program that requires two ports for serial communication. I intended to use both hardware serial and software serial, but the problem is receiving data from receiving buffer of the software serial: it always returns zero byte from myserial.available().

For clarity I used the software serial example in Arduino IDE ver. 1.8.4.
I tried to change the baud rate but still the problem persists. I read somewhere that they made some code changes in the SoftwareSerial library's .cpp and .h files. I tried to find the site without success. And my PC where I installed those libraries was stolen. Before that it was working properly.

The mistake I made is that I just copied the code and pasted in the library without concentrating on it. Here is the example of program with two serial ports.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); // RX, TX

void setup() {
  Serial.begin(57600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  Serial.println("Goodnight moon!");
  // set the data rate for the SoftwareSerial port
  mySerial.begin(4800);
  mySerial.println("Hello, world?");
}

void loop() {
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}


texts: How to install a library for a single project

texts:
How do you install an Arduino library so it's only available for a specific project?

Say I have a codebase located at /myproject, and I want to install libraries at /myproject/lib/somelib. I can't find how to make arduino myproject.ino find the libraries under ./lib.

Googling "installing Arduino libraries" only finds me examples of installing libraries globally (and through the GUI no less), which is horrible practice and guarantees version conflicts.

When I used ino, it supported a local ./lib directory, but I can't find any equivalent feature in arduino.


texts: How to multitask with interrupts on Arduino?

texts: I am trying to build a cashless RFID based water dispensing unit. I am using Arduino mega 2560, PN532, relay, flow sensor. Here is the flow of the program in I2C mode; I have two functions, one to scan the card and the other for the flow sensor. As soon as the RFID card is placed on the NFC module, data stored in the card (i.e, date of expiry and balance amount) is obtained and is checked for validity. If the card is valid, then the relay is turned on. A flow sensor measures the quantity of water dispensed. As soon as the limit of 1000 ml is reached, the relay is turned off. The whole process happens serially, when the card scanning is complete, it waits for the entire 1000 ml of water to be dispensed. What I want to achieve is after one card is scanned, 1st relay with the flow sensor has to be turned on and simultaneously the scanning of the second card has to begin. If the first relay is busy, second relay has to be assigned to it. Can I achieve this using Arduino Mega? How do I manipulate the atmega to perform all these tasks at once?


texts: PS2 Keyboard and sending keystrokes between a Leonardo and several pro micros

texts:
I am working on a project where I am taking the the key presses from a PS/2 keyboard and passing them to several pro micro boards so I can type the same commands on multiple computers at the same time. I have a master board that is a Leonardo that is connected to a keyboard. Using the TX pin I am connecting to a pro micro and trying to receive keystrokes on the micro and output them to a computer. I can get a the keyboard to work with the Leonardo connected to computer but not the pro micro. What do I have wrong about communication between these devices.(I get maybe every other key correctly on the computer but a also other keys or even function keys.)  Code for the "Master":

#include <PS2Keyboard.h>
#include <Keyboard.h>

const int DataPin = 8;
const int IRQpin =  3;

PS2Keyboard keyboard;

void setup() {
  delay(1000);
  keyboard.begin(DataPin, IRQpin);
  Serial.begin(9600);
  Serial1.begin(9600);
  Serial.println("Keyboard Test:");
}

void loop() {
  if (keyboard.available()) {

    // read the next key
    char c = keyboard.read();

    // check for some of the special keys
    if (c == PS2_ENTER) {
      Serial.println();
    } else if (c == PS2_TAB) {
      Serial.print("[Tab]");
    } else if (c == PS2_ESC) {
      Serial.print("[ESC]");
    } else if (c == PS2_PAGEDOWN) {
      Serial.print("[PgDn]");
    } else if (c == PS2_PAGEUP) {
      Serial.print("[PgUp]");
    } else if (c == PS2_LEFTARROW) {
      Serial.print("[Left]");
    } else if (c == PS2_RIGHTARROW) {
      Serial.print("[Right]");
    } else if (c == PS2_UPARROW) {
      Serial.print("[Up]");
    } else if (c == PS2_DOWNARROW) {
      Serial.print("[Down]");
    } else if (c == PS2_DELETE) {
      Serial.print("[Del]");
    } else if (c == PS2_F1) {
      Serial.print("[F1]");
      //Serial1.print("[F1 ]");
    } else {

      // otherwise, just print all normal characters
      Serial1.print(c);
    }
  }
}

Code for the "Slave":

#include <HID.h>
#include <Keyboard.h>

void setup(){
   Serial1.begin(9600);
   Serial.begin(9600);
   Keyboard.begin();
}

void loop(){
   if (Serial1.available() > 0) {
   // read incoming serial data:
   char c = Serial1.read();
   Keyboard.print(c);
  }
}


texts: FTDI and 16u2 (Uno) Baud rate limitations

texts:
I'm trying to test the maximum speed at which I can send data to an Arduino based on the ATMega328p, using a USB to Serial converter like the FT232RL or the ATMega16u2 that is used on the Uno.

I've borrowed some code from here: https://www.pjrc.com/teensy/benchmark_usb_serial_receive.html

I'm using his receive_test code on Windows, to test what I can achieve in terms of sending data to the Arduino, for the sake of using it to control LED strips.

On the Arduino side, I'm testing with the following:

static int count = 0;
unsigned char data = 0;
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
  //UART Initialisation
  UCSR0A |= (1<<U2X0);
  UCSR0B |= (1<<RXEN0)  | (1<<TXEN0) | (1<<RXCIE0);
  UCSR0C |= (1<<UCSZ01) | (1<<UCSZ00)             ;
  UBRR0H = 0;
  UBRR0L = 3; //Baud Rate 0.5 MBit   --> 0% Error at 16MHz :-)

  sei();
}

ISR(USART_RX_vect)
{
  static unsigned char b;

  b=UDR0;
  data = b;
  count++;
}

byte pinstate = LOW;

void loop() {
  while (count < 500);
  count = 0;
  // toggle pin 2, so the frequency is kbytes/sec
  if (pinstate == LOW) {
    digitalWrite(led, HIGH);
    pinstate = HIGH;
  }
  else {
    digitalWrite(led, LOW);
    pinstate = LOW;
  }

  // Delay for 500 microseconds, to simulate doing
  // something useful with the received data
  //unsigned long beginMicros = micros();
  //while (micros() - beginMicros <= 500); // wait 500 us
}

In theory it should run at 0.5Mbps (460800 baud).
However, on Windows I can only seem to transfer data at up to 12KBps (96Kbps). It transfers at this speed regardless of what the baud rate is set to on the arduino or PC side. Which is weird because if I set it to 9600 baud it should run at 1/10th the speed, but it ALWAYS runs at that speed. The only difference I ever see is that on Linux/Mac it runs at closer to 40KBps.

So, it seems like there is a bottleneck somewhere, but I can't seem to figure out where. Everything I read says it SHOULD be able to run faster than this.

Any thoughts?


texts:
This is my first program on Arduino Uno (the starter kit), although I do have prior experience with programming (JavaScript, coding class last year 7th grade). It blinks the internal led (pin 13) in a Morse Code message:

.... . .-.. .-.. ---   .-- --- .-. .-.. -..
. = dit();

- = dah();

(interval between parts of letter) = wip();

(interval between letters/words) = wah();

Here's my code:
/*
 * Roman's first program
 * Decipher the message!
*/

int ledPin = 13;
int index = 0;

void setup() {
  //initialize pins as outputs
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int sequence[] = {1,0,1,0,1,0,1,3,1,3,1,0,2,0,1,0,1,3,1,0,2,0,1,0,1,3,2,0,2,0,2,3,3,3,1,0,2,0,2,3,2,0,2,0,2,3,1,0,2,0,1,3,1,0,2,0,1,0,1,3,2,0,1,0,1};
  int arrLength = sizeof(sequence)/sizeof(int); //however THIS works?!
  if (index < arrLength-1) { //0-based array
    index++;
  } else {
     index = 0; //restart the sequence once finished
  }
  if (sequence[index] == 0) {
    wip();
  } else if (sequence[index] == 1) {
    dit();
  } else if (sequence[index] == 2) {
    dah();
  } else if (sequence[index] == 3) { //because sometimes I the values are screwed past arrLength...
    wah();
  }
  //Serial.println(String(sequence[index])+" , "+String(index));
}

void dit () {
  digitalWrite(pinMode, HIGH);
  delay(300);
  digitalWrite(pinMode, LOW);
}

void dah () {
  digitalWrite(pinMode, HIGH);
  delay(900);
  digitalWrite(pinMode, LOW);
}

void wip () {
  delay(900);
}

void wah () {
  delay(2100);
}

Yet nothing is happening, except for the four/five startup flashes on the led when I restart it (red button). And yes, I saved and compiled.