text:
Is my leonardo broken? Is there a way to make it work?
backgrounds
I bought arduino leonardo and connect it to Ubuntu 15.04.
With arduino IDE 1.0.5(from Ubuntu official repo) running in sudo, the arduino was recognized as /dev/ttyACM0.
So I tried to upload sample sketch Blink to the port ttyACM0 with settings of Leonardo, but every time I tried to upload IDE said that serial port is wrong. and then actually leonardo was recognized as ttyACM1. If I set ttyACM1 and retry, leonardo moved to ttyACM2; and so on.
So I searched some websites and installed oracle-java7-installer package and Arduino IDE 1.6.5 from official site.
After doing so and several tries, my leonardo finally stopped to be recognized. no ttyACMx appears from that time.
I guessed it's the problem on software environment, so I connected the arduino to Windows7 pc, but device manager also didn't recognize the arduino.
How my leonardo is now
Connecting to PC, "ON" LED have turned on and "L" LED blinks each 1 seconds. I guess it's thanks to default bootloader.
So looks not completely broken or bricked, but still can't access from any PC in normal way.
What I want to be taught
Is my leonardo broken?
Is there a way to make it work?

reply(20151018)
@Chris Stratton
Thank you for suggesting! It's good news for me that it doesn't seem to broken.
I ran lsof | grep ttyACM and found nothing.
And about brltty, Ubuntu has installation of it by default, and sudo service brltty status says its enabled.
So I try sudo service brltty stop and connect my Leonardo, but it still not be recognized. X(

First, never run programs like the Arduiono IDE as root!  It's insecure, and it can make a mess by creating files which a normal user account can't clean up.  Add yourself to the dialout group instead.

The "migrating" USB serial device problem is a behavior of typical Linux configuration (probably udev) - if a device is disconnected (possibly including by simple reset of the target processor) from the USB bus while anything has the device file open, when reconnected it will not be given that same name, but the next one in the sequence of naming rules.  This can be quite annoying when doing embedded development, and I've been thinking about trying to change that behavior for select devices.  In the meantime, you can use lsof | grep ttyACM to see if something still has the old one open.

And make sure to disable brltty if you have that installed - it can improperly grab serial devices, and it could be something like that which is preventing re-use of the serial device names.  It's unlikely your Leonardo is bad - it has to be fairly alive to be given a serial device name.  At an extreme you could try reloading its firmware in DFU mode, but that's probably unecessary.  Can you use a friend's Mac or Windows box to test it?


text:
Lego Technic Servo Motor - 9V PWM
I want to control Lego Technic Servo Motor 88004.
The way it works is - Lego has a 4 cable connector. Two of them supply power (+9V & GND) and the other are optionally +9V and they are called C1 and C2.
Servo turns right or left max 90 deg when you supply PWM to either C1 ("left") or C2 ("right"). (or the other way round, but it doesn't really matter)
That basically means that what I need is a 9V PWM and be able to supply it to either C1 or C2. What is more the frequency has to be 1150 Hz.
Now the question is how do I achieve this goal?
I'm already using the L298N motor controller and happen to have one engine slot free.
1) If I can supply PWM from Arduino to "LNA" input in L298N - will it also cause the output to be PWM?
Because L298N has a transistor I have a feeling that the output is also going to be PWM unless there's something else there i.e. capacitor
Even if it's not does that matter at all - meaning is it going to still work?
2) How do I produce PWM with 1150 Hz from Arduino? My Arduino is 16MHz so I suppose that it should be possible to switch output with order of magnitude smaller frequency.
If what I'm trying to do makes no sense please try to point me to the right direction.

I'd be surprised if some web searching didn't turn up existing mentions of driving these motors from an MCU, perhaps even your Arduino's ATmega.  Even if you want to work it out yourself, this could be advantageous to research first as a cross-check on your beliefs about the signal properties.

My guess it that C1 and C2 will work just fine with only 5Volt.

The search did not return any instruction on how to drive the servo. There's a lot of articles about motors. Everything that I'm writing is based on research I did.

@gerben yes, but you can't do 90 deg and I'm worried about the max 5 mA current

Yes, the output will be a pwm. You can see it from the schematics.
you have few options, with different precision and complexity:

Configure one of the PWM HW blocks
Do it by sw in a loop
Use a timer to trigger a sw function - but it might be simpler to just configure the PWM HW block.
Use some existing library that will implement one of the methods I listed

I would recommend Option 1: it's not so difficult, you will learn something of the AVR internals and it will be the solution with the least overhead. You can have a look at this tutorial. There are also many others floating around.

Igor thank you very much for your answer! One more thing that bothers me - I suppose that when I'll be applying voltage to C1 then C2 should probably be floating and vice versa. If I simply connect C1 and C2 to outputs from L298N then the second one is going to be pulled to ground. I'll do some research to confirm if pulling the second one to ground is dangerous or not, but supposing it is - what would be the simplest option to avoid it? Using some kind of demultiplexer?

If you leave it floating, chances are that it can pickup some noise.
Checking the circuit is always he best course of action.
If you are worried about shorts, you can use a pull-down resistor, instead of connecting directly to ground.

According to this: https://www.youtube.com/watch?v=i_4d-XsgdA0 youtube video I can safely pull one of them to ground :) That means that using the motor bridge should be sufficient to be able to operate the servo :) About option 1 - the closest I can get to 1150 Hz is 1kHz but maybe I don't need to be precise about the frequency. Time will show..

If they work like the L298N (and that's a big if), they might even support the extra modes: both to ground for free spinning motor, both high for emergency arrest (the motor locks in place, beware of the current/voltage spikes).

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Need to power Arduino Mega 2560 with 3.3V
I found an LCD for my Arduino Mega 2560 that's parallel (I like that, I don't like SPI), but it works at 3.3V and isn't 5V tolerant. That's why I'd need to use level shifters, but that would use too much space and I'd like to power the microcontroller with 3.3V. But that would cause problems because the USART communication is set to be on 5V and that can't be changed.
Is there a way to power my Arduino at 3.3V? Is there an alternative Arduino for that?
Also, if there is, I'd need to have a 16MHz crystal on it. I know it's overclocking, but Gamebuino works at 16MHz on 3.3V and I would like to do the same.

Maybe a Due would be more suitable for you...?

You can use pro mini 3.3v and one shift register. It is not SPI :)

Some of the smaller boards may not have enough I/Os.  Typically the ARM-based boards are native 3.3v, with more memory and faster too.  Level shifting the serial shouldn't be too hard.

It must be ATMEGA2560 because of the pin count and XMEM for the display. My project is to make an 8-bit AVR game console with most RAM as possible and a fast LCD. It's something like those NTSC projects, but mine is a handheld console. If I have to, I can work in full ASM.

SPI into a shift-register is pretty fast. If space is a premium I would have thought that the Mega2560 board was a little large.

Have you considered maybe using the Iteaduino MEGA2560?
The Iteaduino MEGA2560
uses the same ATmega2560 processor as the Arduino Mega 2560,
but is physically much smaller, the size of a Arduino UNO.
It has a switch to run the ATmega2560 at 3.3 V, so its I/O pins can be directly connected to 3.3 V modules.
It breaks out all the GPIO pins of the ATmega2560,
so it actually has more I/O on its connectors than the Arduino Mega 2560.
If I'm reading this right, the Iteaduino schematics and a typical Iteaduino features list
seems to say it already has a 16 MHz crystal.

Can I connect an external 16MHz crystal there?

Have you considered maybe using the "Sparkfun Mega Pro 3.3V" plus a "SparkFun FTDI Basic Breakout - 3.3V" ?
It uses the same ATmega2560 processor and has the same I/O arrangement as the Arduino Mega 2560, but it runs off 3.3 V.
It doesn't have the 16 MHz crystal you wanted, but if you really insist on overclocking, perhaps you could replace its 8MHz resonator with a 16 MHz crystal?

I don't see where the resonator is. I don't see the pin to connect it to either. Can you show me?

Does that doodle on a photo answer your question?

I see. I hope that I won't damage it or the MCU while unsoldering. What kind of a soldering device should be used there?

Wide chisel tip soldering iron with a big blob of solder to take it off the board. Soldering braid to clean up the pads. Narrow fine-tip soldering iron to attach new parts to the pads. A better place to ask questions about soldering techniques: http://electronics.stackexchange.com/questions/tagged/soldering .

Have you considered maybe using the Inhaos Buono Mega 2560 (see a), also called the Inhaos Mega2560?
As far as I can tell, it is pretty much identical hardware as the Arduino Mega 2560 -- including the ATmega2560 processor -- except it has a selector to run the ATmega2560 at 3.3 V, so its I/O pins can be directly connected to 3.3 V modules.
Like many websites, every page on the Inhaos website http://www.inhaos.com/ has a "Contact Us" link at the top of each page. Click that link to get a list of several ways to contact the company.

This one is the best, but unfortunately, it's no longer for sale. Is there a way to buy it somewhere or to contact the company?

As far as I can tell, the "Inhaos Mega2560" is still for sale. I added more links to this answer; does that answer your question?

Have you considered maybe using the ElecFreaks Freaduino MEGA2560 ?
It has an identical I/O arrangement and dimensions as the Arduino Mega 2560 -- including the ATmega2560 processor. It has a selector to run the ATmega2560 at 3.3 V, so its I/O pins can be directly connected to 3.3 V modules.
The voltage regulators and reset switch position are better than the Arduino Mega 2560.

What about a 3.3v Arduino Pro Mini, you'll need to solder headers but that's not too onerous. See here Arduino pro Mini or even cheaper from eBay

Is there a 2560 version of that?

Not that I'm aware of. What's the 2560 specific functionality that you require?

XMEM access to external RAM and the display for super speed. It's for my 8-bit handheld console project with maximum RAM and fastest color display.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Why doesn't PWM work on arduino in this code?
I am trying to control a dc motor speed with PWM. When I test it with simple program like spin in one direction with set PWM value it works. If PWM>70 the motor will start spinning and max is 255.
But when I try to do the same in code below it only spins if PWM value is 255. Can someone help me?
test.ino

/*--------------------*/
// encoders
/*--------------------*/
//motor_encoder
int encoder0PinA = 3;
int encoder0PinB=2;
volatile int encoder0Count = 0;
volatile float angle0 = 0;
volatile float velocity0 = 0;
volatile float angle0_previous = 0;
volatile float angle0_post = 0;
//pendulum_encoder
int encoder1PinA = 20;
int encoder1PinB = 21;
volatile int encoder1Count = 0;
volatile float angle1 = 0;
volatile float velocity1 = 0;
volatile float angle1_previous = 0;
volatile float angle1_post = 0;
float error=0;
/*--------------------*/
// motor
/*--------------------*/
int enA = 10;
int in1 = 9;
int in2 = 8;
/*--------------------*/
// for Timer2
/*--------------------*/
volatile int tcnt2 = 131;
volatile int t = 0;

volatile float error_proportional = 0;
volatile float error_derivative = 0;
volatile float error_integral = 0;
float kp =50;
float kd = 0;
float ki = 0;
float u = 0;
float motor_input = 0;
int INPUT_MAX = 255;
int P=0;
int I=0;
int D=0;
int integral=0;
void setup()
{

  pinMode(enA, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);

  /*--------------------*/
  // for encoder
  /*--------------------*/
  // for encoder 0
  pinMode(encoder0PinA, INPUT);
  pinMode(encoder0PinB, INPUT);
  attachInterrupt(0, doEncoder0A, CHANGE);
  attachInterrupt(1, doEncoder0B, CHANGE);
  // for encoder 1
  pinMode(encoder1PinA, INPUT);
  pinMode(encoder1PinB, INPUT);
  attachInterrupt(2, doEncoder1A, CHANGE);
  attachInterrupt(3, doEncoder1B, CHANGE);

  /*--------------------*/
  // for Timer2
  /*--------------------*/
  // interrupts every 1 ms
  TIMSK2 &= ~(1<<TOIE2);
  TCCR2A &= ~((1<<WGM21) | (1<<WGM20));
  TCCR2B &= ~(1<<WGM22);
  ASSR &= ~(1<<AS2);
  TIMSK2 &= ~(1<<OCIE2A);
  TCCR2B |= (1<<CS22)  | (1<<CS20);
  TCCR2B &= ~(1<<CS21);
  TCNT2 = tcnt2;
  TIMSK2 |= (1<<TOIE2);

  Serial.begin (9600); // for debugging
}

void loop()
{

 error = angle1;

 if (abs(error) < 2){
 integral = integral + error;
 }
 else {
 integral=0;
 }
 P = error*kp;
 I = integral*ki;
 D = (angle1_previous-angle1)*kd;
  u = P + I + D;
  motor_input = 255/24 * u;

  Serial.print("u: ");
  Serial.print( u);
  Serial.print(" ");
  motor_input = (int)motor_input;

  if (motor_input >= INPUT_MAX){
    motor_input = INPUT_MAX;
  }
  else if (motor_input <= -INPUT_MAX){
    motor_input = -INPUT_MAX;
  }

  Serial.print("error_proportional: ");
  Serial.print(error_proportional);
  Serial.print(" ");
  Serial.print("error_derivative: ");
  Serial.print(error_derivative);
  Serial.print(" ");
  Serial.print("error_integral: ");
  Serial.print(error_integral);
  Serial.print(" ");
  Serial.print("motor_input: ");
  Serial.println(motor_input);
  setMotorSpeed(motor_input);
}

measure_states.ino
/*--------------------*/
// enkoder od motora
/*--------------------*/
void doEncoder0A(){
  if (digitalRead(encoder0PinA) == HIGH) {
    if (digitalRead(encoder0PinB) == LOW) {
      encoder0Count = encoder0Count + 1;
    }
    else {
      encoder0Count = encoder0Count - 1;
    }
  }
  else {
    if (digitalRead(encoder0PinB) == HIGH) {
      encoder0Count = encoder0Count + 1;
    }
    else {
      encoder0Count = encoder0Count - 1;
    }
  }
  angle0 = 0.000785*encoder0Count;  // radian  (2*pi/8000)
}

void doEncoder0B(){  // interrupt 1 function
  if (digitalRead(encoder0PinB) == HIGH) {
    if (digitalRead(encoder0PinA) == HIGH) {
      encoder0Count = encoder0Count + 1;
    }
    else {
      encoder0Count = encoder0Count - 1;
    }
  }
  else {
    if (digitalRead(encoder0PinA) == LOW) {
      encoder0Count = encoder0Count + 1;
    }
    else {
      encoder0Count = encoder0Count - 1;
    }
  }
  angle0 = 0.000785*encoder0Count;
}

/*--------------------*/
// for encoder 1
/*--------------------*/
void doEncoder1A(){
  if (digitalRead(encoder1PinA) == HIGH) {
    if (digitalRead(encoder1PinB) == LOW) {
      encoder1Count = encoder1Count + 1;
    }
    else {
      encoder1Count = encoder1Count - 1;
    }
  }
  else {
    if (digitalRead(encoder1PinB) == HIGH) {
      encoder1Count = encoder1Count + 1;
    }
    else {
      encoder1Count = encoder1Count - 1;
    }
  }
  angle1 = 0.000785*encoder1Count;
}

void doEncoder1B(){
  if (digitalRead(encoder1PinB) == HIGH) {
    if (digitalRead(encoder1PinA) == HIGH) {
      encoder1Count = encoder1Count + 1;
    }
    else {
      encoder1Count = encoder1Count - 1;
    }
  }
  else {
    if (digitalRead(encoder1PinA) == LOW) {
      encoder1Count = encoder1Count + 1;
    }
    else {
      encoder1Count = encoder1Count - 1;
    }
  }
  angle1 = 0.000785*encoder1Count;
}

ISR(TIMER2_OVF_vect) {
  TCNT2 = tcnt2;
  t++;

  // estimate velocity
  if (t == 1){
    angle0_previous = angle0;
    angle1_previous = angle1;
  }
  else if (t == 20){
    angle0_post = angle0;
    angle1_post = angle1;
  }
  else if (t == 21){
    velocity0 = (angle0_post - angle0_previous)*50;  // rad/s
    velocity1 = (angle1_post - angle1_previous)*50;

    error_proportional = 3.1416 - angle1;
    error_derivative = 3.1416 - velocity1;
    error_integral = error_integral + error_proportional;

    t = 0;
  }
}

motor.ino
void setMotorSpeed(int speed)
{
  if (speed < 0)
  {
    digitalWrite(in1, LOW);
    digitalWrite(in2, HIGH);

  }
  else
  {
    digitalWrite(in1, HIGH);
    digitalWrite(in2, LOW);

  }

  analogWrite(enA,abs(speed));

  angle1_previous=angle1;
}

UPDATE 1:
I found that the code below for setting timer messes PWM but Im not sure why. Anyone have any idea?
TIMSK2 &= ~(1<<TOIE2);
  TCCR2A &= ~((1<<WGM21) | (1<<WGM20));
  TCCR2B &= ~(1<<WGM22);
  ASSR &= ~(1<<AS2);
  TIMSK2 &= ~(1<<OCIE2A);
  TCCR2B |= (1<<CS22)  | (1<<CS20);
  TCCR2B &= ~(1<<CS21);
  TCNT2 = tcnt2;
  TIMSK2 |= (1<<TOIE2);

Arduino core uses built in timers to perform PWM - setting them manually using the AVR registers messes it up. This may be helpful - see the part where it says which timer corresponds to which pins.

In loop(), after you set P, I, D, and u, it looks like you mean to calculate motor_input in float, but the calculation is will be partially done in int. The compiler will precalculate (int)255 / (int)24 as (int)10. At run time, that will be floated to 10.0 and multiplied by u. If you really meant the multiplier to be 10.625 (the result of a floating divide), at least one of the two constants, 255 and 24 needs a decimal point to indicate that. I see that in your initializers, too. ...

... Use a decimal point, a trailing 'F' or 'D' (for 'float' or 'double') in your numerical constants that you expect to be treated by the compiler as double, float, or double, respectively (doubles and floats will be the same on an Arduino). I doubt this will solve your motor no-start issue, but it will affect your controller.

!!Ach!! I failed to notice this was an obsolete post. Well, maybe my comment will do someone, somewhere, somewhen, some good...  :(

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Problem in receieving message
I'm working on a project in which when I press reset button the arduino should send longitudes and latitudes to my phone. I'm a beginner and tried to join two codes, first code can send the message and the second code can get the lon and lat printed on the serial monitor.
First code--
int timesTosend=1;
int count=0;
char phone_no[]="+917771914436";
void setup()
{
  Serial.begin(9600);
  delay(2000);
  Serial.println("AT+CMGF=1");
  delay(200);
}
void loop()
{
  while (count<timesTosend)
  {
    delay(1500);
    Serial.print("AT+CMGS=\"");
    Serial.print(phone_no);
    Serial.println("\"");
    while(Serial.read()!='>');
    {
      Serial.print("Hii If this message is sent then its a huge sucess for me");
      delay(500);
      Serial.write(0x1A);
      Serial.write(0x0D);
      Serial.write(0x0A);
      delay(5000);
    }
    count++;
  }
}

Second code--
#include <SoftwareSerial.h>
#include <TinyGPS.h>

long lat,lon; // create variable for latitude and longitude object

SoftwareSerial gpsSerial(4, 3); // create gps sensor connection
TinyGPS gps; // create gps object

void setup(){
  Serial.begin(9600); // connect serial
  gpsSerial.begin(9600); // connect gps sensor
}

void loop(){
  while(gpsSerial.available()){ // check for gps data
   if(gps.encode(gpsSerial.read())){ // encode gps data
    gps.get_position(&lat,&lon); // get latitude and longitude
    // display position
    Serial.print("Position: ");
    Serial.print("lat: ");Serial.print(lat);Serial.print(" ");// print latitude
    Serial.print("lon: ");Serial.println(lon); // print longitude
   }
  }
}

My code which is not working--
#include <SoftwareSerial.h>
#include <TinyGPS.h>
long lat,lon; // create variable for latitude and longitude object

SoftwareSerial gpsSerial(4, 3); // create gps sensor connection
TinyGPS gps; // create gps object

void setup()
{
  Serial.begin(9600); // connect serial
  gpsSerial.begin(9600); // connect gps sensor
    Serial.begin(9600);
  delay(2000);
  Serial.println("AT+CMGF=1");
  delay(200);
}

int timesTosend=1;
int count=0;
char phone_no[]="+917771914436";
void loop()
{
  while (count<timesTosend)
  {
    delay(1500);
    Serial.print("AT+CMGS=\"");
    Serial.print(phone_no);
    Serial.println("\"");
     while(Serial.read()!='>');
    {
      while(gpsSerial.available())
      {
        if(gps.encode(gpsSerial.read()))
        { // encode gps data
    gps.get_position(&lat,&lon); // get latitude and longitude
    Serial.print(lat,lon);
      delay(500);
      Serial.write(0x1A);
      Serial.write(0x0D);
      Serial.write(0x0A);
      delay(5000);
        }
      }
    }
    count++;
  }
}

Please help me out by correcting my mistake in the code.

Serial.print(lat,lon);

That doesn't do what you think it does.  That is trying to print the latitude encoded in base "lon", which just isn't going to work.
Instead you need to send it as separate operations:
Serial.print(lat);
Serial.print(",");
Serial.print(lon);

Also you should separate out the GPS and GSM routines.  Create a function that gets the latitude and longitude, and another function that sends the two values as a text message.  Then you can keep things as discrete obvious steps and not get confused with what is happening when.

Then please tell me what can I do to send it as text message?


text:
The Time are functions do not work correctly when the processor clock speed is set at 128K
How can I change The timers to work correctly when The processor clock is set to 128K instead of 16 M?
At present, using the delay function does not work correctly, The delay is far too long.

Your solution that makes perfect sense, however, it would be a mammoth task going updating the delay functions used in third-party libraries.

Surely, there must be some way to scale down the clock counters?

Add a new entry in boards.txt with the new value for f_cpu. Note that the timing functions will become far less precise at so low a speed.

I have tried changing bored.TXT, however, this seems to make no difference.

You have to select the new board that you have created in the Arduino IDE.

A commonly-used approach is writing an intermediate or surrogate delay function that your application calls.  That delay routine needs a way to know if the clock is slow (128 KHz) or fast (16 MHz).  If the clock is slow, divide the delay counts by 125 (the ratio of 16 MHz and 128 KHz) before calling the built-in delay().  [Or, adjust all your application calls to use numbers scaled down by a factor of 125, and in the surrogate scale them back up if the clock is fast.  This may give you better control than just rounding, truncating, or truncating up will do.]
For example, if you call the intermediate routine vDelay() and change your app calls from a delay(x) form to a vDelay(x) form, in the function vDelay(unsigned long ms) you will say something like if (ClockIsSlow) delay((ms+124)/125); else delay(ms);


text:
Esp8266 V12 Wiring
I have tried a Google search and cannot find any place that tells me exactly how to wire the version 12 esp8266 ,
How should it be wired for normal operation and for flashing ?
I am designing a diy pcb and need to know the specifics,to wire a switch for flashing purposes etc.I am using just a esp8266 version 12 standalone without a typical arduino micro-controller attached and will be flashing it to take the arduino ide ,any help with this would be great as I'm sure someone has already come across this problem.

You could find the solution, on the first hit for googling "ESP8266 ESP-12".

You need to connect a few GPIO pins on the ESP-12 to 3.3V or Ground,
  to set it in the right mode for communicating with it. Here are the
  connections you need to make :
VCC ----> 3.3V Power supply (Vout of LM1117)
GND ----> Ground of power supply
CH_PD ----> HIGH (3.3V)
GPIO2 ----> HIGH (3.3V)
GPIO15 ----> LOW (GND)
GPIO0 ----> HIGH or Floating for AT Mode (3.3V) [ * if you want to
  flash completely different firmware then you must connect it to ground
  ]

You need to connect GPIO0 to GND for flashing and to VCC for normal operation.

Thank you ,i wasn't sure where to believe as their seemed to be conflicting information but this could be due to different configurations,thank you for answering my question at least i can be sure now.Thank you


text:
Switch MPU6050 to send SCL data through A4 and SDA through A5
I have this MPU6050, and like most of the other MPU6050s, it is set up for SCL to be attached to A4 and SDA to be attached to A5. I have this shield on my Arduino Uno, which is configured for Sainsmart's (the company who made the shield) MPU6050, so the special MPU6050 pins are set up V, G, A5, A4, and my current setup needs V, G, A4, A5. I am using the built-in Wire library, I2CDev library, and the MPU6050 library. So I am wondering whether there is something in these libraries that define which pins it looks for my MPU6050 on, and if so how do I change it.

The pin definition is in hardware. There is nothing you can do to change it. However you could try to reprogram it to use a software i2c library instead of the hardware wire library.

Which would be the best one to use

@user10529 Which what?

Why not build a small board that converts the pins from V, G, A5, A4 to V, G, A4, A5? Or modify the PCB e.g. cut and rewire the signals in the order you want. It is only two pins!
Cheers!


text:
Choosing Right Power Supply for Arduino - ESP8266 - HC-SR04
If I make connections like you see in picture below, will it work? Will I damage ESP or HC-SR04?
As I know;
HC-SR04 (VCC) -> 5V
ESP8266 (VCC) -> 3.6V
ESP8266 (RX/TX) -> has 5V tolerance ?
I have not taken into account the currents that will each pin draw. So, is everything OK?
I'm not good at this stuff, so I'll appreciate it if you guys give me advice
Image

Most of you suggest to use voltage regulator instead of external AA batteries. However, I have already ordered one but it takes too much time (nearly week) to get, due to delivery-shipping issues. So, I want to work on the coding part of my project.

The voltage regulator would be used in conjunction with not instead of the batteries. Regulators do not supply power by themselves.

Three freshly charged NiMH cells can easily exceed 3.6v, and if someone substitutes alkalines, potentially by a lot.

GND seems dangling.
If you are going to use multiple power sources, make sure that all the minus/GND are connected together.
Whether the ESP8266 can use 5V or not should be checked against the actual unit you have. There are many variants and some might be more tolerant than others.
You do not show the power source for 5V - what is it?
By just typing on google HC-SR04 5V, you get a link to the manual, which has a section "4.0 PRODUCT SPECIFICATION AND LIMITATIONS": Min:4.5V Typ:5V Max:5.5V. You should at least give it a try and report your findings, asking for clarifications, if you need any, rather than just ask here for something that google can provide.

1- I didn't get what you mean by saying 'dangling'
2- I noticed that and connected them together.
3- I searched and checked it has 5 V tolerance.
4- No reason for connecting 5 V to board, I just made it if I need later.
I'll try now and let you notify the latest results. I hope I won't make something damage and useless.
thx for suggestions

When you get the wiring sorted out, remove the batteries and plug in the USB, that should power it up and allow you to start writing your code.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Can one supply an Arduino Zero's VIN pin with 5v?
The title pretty much says it all. I know that most Arduinos can do this, but I couldn't find very much information for the Zero. Any help would be very much appreciated.

Yes you can. If you look at the schematics on the Arduino website you can see that the 3.3 volt regulator is connected to the 5 volt regulator. That means that if you feed 5 volts straight into the 5 volt pin it will go through the 3.3 volt regulator to supply the main chip.
Note that this is going into the 5 volt pin not the VIN pin which goes into the 5 volt regulator and would thus require a higher voltage than 5 volts.


text:
What wrong with that code?
Hi i have made this code
its so simple its should receive data from the computer and send it back via the serial but the problem is he do not what it is suppose to do
when its run its keep sending -1 to the computer
and if i send something to the arduini  like  55   i receive and answer 53
i have no idea were is the problem in this code
long number = 0;

void setup() {
  Serial.begin(9600);
}
   void loop() {
   number = Serial.read();
   delay(1000);
   Serial.println(number);
}

Serial.read() returns -1 when there was nothing to read. Just discard the -1.

here i made so change to the code the value for  number is no longer 5   now its 0 and i changed int for long and therer no longer int before  number = Serial.read();          when i send 3  its answer me 51 10

When you send a 3 what answer do you expect?

@EricCooper True, if you send "3" you'll get ASCII 51, ASCII 10. (http://www.asciitable.com/index/asciifull.gif)
The NUMBER 51 is CHARACTER "3" also, a newline character (10) is added to the end of your serial message when you send it.

You need to include DEC as the second argument to the Serial.println() call to get the correct numbers out.  Read up on this here: Arduino Serial Print.
In other words, make change below:
Serial.println(number, DEC); // DEC is needed to get the correct values

I didn't even know this, but it's worth noting that he's printing the ASCII representive of the sent character.

Serial.read() returns one character from the input. Serial.println will try to convert a variable into ASCII characters, and print that. Your variable, number gets the ASCII code of the first typed character in its first byte. The Serial.println call will interpret that and the next 3 bytes (whatever they happen to be...?) as a value to be printed.
Your problem is in not understanding the conversion of digit strings into values and vice-versa, and of how the Serial.xxx functions work.
You'll need to collect the terminal input character-by-character into an array, then convert it to a numeric value (assuming you're eventually going to do more with it than print it back out). Then you could Serial.println() that (or another) value out to the terminal.


text:
Read sensor and convert reading to const char*
I'm working on a home automation project using Arduino and MQTT.
I've found a problem and my limited programming knowledge find a way to solve it.
I can send text trough MQTT normally, using
client.Publish("some/topic","Some text here");

But when I try to send a variable (int, char, etc), the compiler says "invalid conversion from 'char' to 'const char*' [-fpermissive]"
How can I store DHT11 sensor reading in const char* to send it?
BTW, I've found this code where
char *tempC;
tempC = dtostrf(((((analogRead(tempPinIn) * 5.0) / 1024) - 0.5) * 100), 5, 2, message_buffer);
client.publish("arduino/temperature",tempC);

is used. But the extra sensor calibration makes it even harder for me to understand whats going on.

The function dtostrf() is prototyped as:
char *dtostrf (double          val,
               signed char     width,
               unsigned char   prec,
               char           *sout);

Where:
   val      Your float variable;
   width    Length of the string that will be created INCLUDING decimal point;
   prec     Number of digits after the deimal point to print;
   sout     Destination of output buffer;

An example of usage is as follows:
/* OPTION ONE */

    char msgBuffer[20];           // make sure this is big enough to hold your string
    char *pointer_to_created_string;

    float testFloat = 123.45;

    pointer_to_created_string = dtostrf(testFloat, 6, 2, msgBuffer);
    client.Publish("...topic...", pointer_to_created_string);

/* OPTION TWO */

    char msgBuffer[20];           // make sure this is big enough to hold your string

    float testFloat = 123.45;

    client.Publish("...topic...", dtostrf(testFloat, 6, 2, msgBuffer));

Don't be put off by the code in the link you included in your question. The first argument sent to dtostrf (everything before the first comma) is nothing more than a some calculations bundled into one single line.


text:
Advanced Line Follower robot
I know about line follower mainly the grid solving robots i know the basics actually. Actually they have to trace the path of the grid in an arena and then reach back to starting point in a shortest distance. Here my doubt is regarding the line follower in this link I have attached.Advanced Line Follower Robot for maze solving
My doubt is what are the procedures to do it? They have mapped the path and used Dijkstra algorithm to solve the path. But how do they transfer the code(i.e) where it has to turn which direction it has to turn. how are they generating the what function should be passed? Please explain i need the procedure alone. am going to try it with python.

Any language will do, as long as it is supported by your HW platform.
If you want to use python, you need a board that can run python.
That could be an Arduino Yun, for example. Or an Intel Quark. Or an Intel Edison with an Arduino shield.
But these will be expensive.
You could, alternatively, use C/C++ and an Ardino UNO (or micro, nano, mini pro), which is far cheaper.
Googling for something as simple as "Arduino line following kit" gives as first answer this, which seems to be exactly what you are looking for.

Please read my question and see the link I have attached.

Why do you think I didn't do that? Try instead with a constructive comment, explaining what of my answer is not matching your question.

Did you see the link? They have just mapped the arena and did it. I want to know the procedures exactly how they did it. I didn't ask whether it will work with python. Arduino works with python-pySerial

I did watch the link, but you need to ask them exactly how they did it.
Other than that, pySerial is not sufficient. It will let you run python code to talk to the arduino, but you need something on the Arduino to listen to it and take the corresponding actions. And send to the PC where your python program is running all the information coming from the sensors.

Oh, wait, are you thinking to continuously poll the sensor over the connection? That might work, but it's kinda lame.

No sir, I just need to know how they did it? I searched many blogs. Actually what kind of implementation is this?


text:
Is it possible to specify a pin upon which the data sent over i2c can act?
A master will send fan speed values to the slave. The slave will then read the fan speed values and change the speed value for the relevant pwm pin. However I am not sure how I can tell the slave which pin the data is for.  Should I send two packets of data in quick sucsession and then have a loop system wherby the first peice of data out of two is always for specifying the pin? Any help in tackling this would be greatly appreciated.

You can use a struct to send multiple things, like this:
#include <Wire.h>

const byte SLAVE_ADDRESS = 42;

struct t_message
{
  byte pin;
  byte speed;
} message;

void setup ()
{
  Wire.begin ();   // initialize master
}  // end of setup

void loop ()
{
  // set desired parameters
  message.pin = 10;
  message.speed = 50;

  // send the message
  Wire.beginTransmission (SLAVE_ADDRESS);
  Wire.write ((byte *) &message, sizeof message);
  Wire.endTransmission ();
}  // end of loop

More information about I2C - Two-Wire Peripheral Interface - for Arduino

On that page is mentioned how to Send and receive any data type. This includes structs. Using the code there you could send a struct, and receive a struct.

Perhaps you should also add the code for the receiver, especially how to extract the struct members

I've expanded my answer.

In a way, yes.  You are making the assumption that many beginners do, that I2C is only able to send one byte.  That's not the case. You can send many bytes as one single packet with I2C.
Send a single packet consisting of two bytes - the first is the pin number and the second the speed.

so how could i tell the two bytes apart when sent in a single packet? could you give a short code example?

You don't need to. They are separate. You just receive one then receive the other.  The first byte you receive is the first one you sent.

how would the counter system work?

@TCarr What counter system?

well the first byte will indicate the pin and the second the fan speed. So how can i differentiate the first byte from the second in a data package?

You don't! It is already done! The first byte in the packet is the first byte in the packet.  I suggest you ask Wikipedia how I2C works so you can understand what I am saying. Do you have a big L on your left hand and an R on your right hand? No? That's because your left hand is your left hand and you don't get it confused with your right hand because it isn't your right hand.

Let us continue this discussion in chat.

@TCarr What is there to discuss? You have all the information you need. Now go read.

The Arduino Tutorial MasterWriter shows you exactly how to do it. https://www.arduino.cc/en/Tutorial/MasterWriter You send 2 bytes from the master and the receiver event is called with howmany set to 2. You read twice, the first is the pin number the second is the fan speed. It's not rocket surgery.


text:
Difference in bootloader of ATmega with 16MHz external crystal and 8MHz external crystal
I have used your bootloader for ATmega2560-16AU with 16MHz external crystal and it works like a wonder.
In my new project I have a 3V power supply. Therefore, I am planning to use a low frequency external crystal in order to operate the ATmega at a low frequency so that the voltage will be able to go as low as possible.
However, I have a number of issues/questions:

I uploaded the bootloader using an 8MHz external crystal and it went successfully but I am not able to upload a sketch.
Can I run an ATmega2560-16AU with an 8MHz crystal and will it work at 3V, without any risk?
As I do not have an ATmega2560-8AU right now, I am not able to test this. Will your bootloader work with Atmega2560-8AU and an external 8MHz crystal or, before burning bootloader, do I need to make any changes?

Sorry to ask you such a long query, but I have really spent lots of time looking at this and finally today I made a post everywhere.

We have 2 optionn.

Yes, the ATmega328 will run fine at 8MHz, at 3 volts.
The formulas for clock speed vs. volts are:

Below 1.8V - cannot operate
Below 4 MHz - use at least 1.8V
Between 4 MHz and 10 MHz you require: Volts = 1.8 + ((M - 4) * 0.15)
(Where M is Megahertz)
Between 10 MHz and 20 MHz you require: Volts = 2.7 + ((M - 10) * 0.18)
(Where M is Megahertz)
You can supply an absolute maximum of 5.5V

Plugging 8MHz into this formula: volts = 1.8+((8-4)*0.15) = 2.4 volts minimum (5.5 volts maximum). Note that, as batteries are used, their voltage goes down gradually, so the 0.6 volts difference will mean that your project will run a little longer.
Since your supply is > 2.7V, we can reverse the second formula: 3V=2.7+(M-10)*0.18); 0.3=(M-10)*0.18; 0.66=M-10, so you can run it at 10.66MHz at 3V (but it is likely to stop as soon as the battery starts to drain).
Your second question, I think, is the most relevant one - the bootloader is written for 16MHz, and some things will not work at other speeds - serial communications used for programming for example. The same, for that matter, applies to the program - if you put in a delay() instruction in your code, it will delay() for twice as long as it should.
You can get around the programming side by ditching the bootloader altogether - once your code is ready, select file->upload using programmer. This will still affect the speed your sketch runs at (anything time-related - serial communications, delay(), etc). To change this, you will need to add a custom entry to the boards.txt file. See [HOWTO:] Anatomy of the boards.txt file for custom boards.

Thank for your input.
But here I asked regarding ATMega2560 8au with 8MHZ crystal. For whom who is looking for this:
http://forum.arduino.cc/index.php?topic=51955.new#new I have not tried below on but it should work:
https://www.sparkfun.com/products/10744 Thank.

Today I just change CPU cycle to 8MHZ and baudrate to 56700 and bootloader works for ATMega2560 8AU with 8Mhz crystal. Just we need to change cpu and baudrate. Thanks.

One may be able to overcome the serial baud rate issue just by talking at half the baud rate configured in the bootloader/sketch - that's not fixing it at the source, but can be a pragmatic workaround if the setup to flash the bootloader isn't handy.  Of course, the timing functions will remain off by a factor of approximatley two as well.


text:
Problem activating HC-05 AT command mode with Arduino Uno Bluetooth shield
Please be gentle with me. I am attempting to modify the configurations of my HC-05 bluetooth module by using the AT command set. The method by which I'm trying to do this is by implementing the following connection:
HC-05 GND --> Arduino GND;
HC-05 3.3v --> Arduino 3.3V;
HC-05 TX --> Arduino Pin 10;
HC-05 RX --> Arduino Pin 11;
HC-05 KEY --> Arduino Pin 9

This is the code which I uploaded to my Arduino (btw my arduino uno is an SMD clone): (code's from http://www.instructables.com/id/Modify-The-HC-05-Bluetooth-Module-Defaults-Using-A/step2/The-Arduino-Code-for-HC-05-Command-Mode/)
#include <SoftwareSerial.h>

SoftwareSerial BTSerial(10, 11); // RX | TX

void setup() {
  pinMode(9, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
  digitalWrite(9, HIGH);
  Serial.begin(9600);
  Serial.println("Enter AT commands:");
  BTSerial.begin(38400);  // HC-05 default speed in AT command more

 }

void loop() {
  // Keep reading from HC-05 and send to Arduino Serial Monitor
  if (BTSerial.available())
    Serial.write(BTSerial.read());

  // Keep reading from Arduino Serial Monitor and send to HC-05
  if (Serial.available())
    BTSerial.write(Serial.read());

}

The problem is I can't seem to activate the AT mode. I don't get any response from the Serial Monitor whatever AT command I try. I double-checked the wiring and it's all good. I can't figure out what the problem is.

I have one question, I was told that you need to reduce the voltage of the Rx pin (pin 2) to 3.3V, otherwise it would have some problems because the Arduino's voltage on pin 11 is 5 V. Does it work in your case?

Yes it works fine. My HC05 is not experiencing any problems. Besides, the Rx pin is a serial pin and it is usually wired directly to the Tx pin of the arduino (which produces pulses of 5V) to make serial communications between the board and the hc05, so I don't think you should reduce it to 3.3V. The rx pin might not be able to read the serial data if the pulse level is reduced.

After 3 hours I magically solved my pretty simple problem myself. If you wired the HC-05 and arduino correctly, the module should indicate that it's in AT Mode by blinking the LED in an interval of 2 seconds. You should get response in the Serial Monitor by typing the AT commands by switching from "No line ending" to "Both NL and CR". That's about it.

In setup() put pin 9 to low, and delay it for about 1 second and then put it to high.

Can you explain how this solves the problem? As written it sounds like a "magic solution" with no explanation about why it works.


text:
Problems connecting reliably using HC-05 (as bluetooth master)
I currently try to connect an Arduino Micro/Leonardo/32u4 to an ELM327 Bluetooth dongle using a HC-05 Bluetooth shield from iTeadStudio. I also have similar problems trying to connect to a bluetooth dongle (with added serial connection) on my PC.
The basic AT-command communication works, but I haven't found out yet why AT+PAIR or AT+LINK are failing and what should be done to avoid this (I've done dozens of Serial Monitor command iterations). Until now I haven't found a command sequence that reliably connects. What I've tried so far (from different documentation and example codes):
Check general AT command set:
AT
> OK

Reset to default values:
AT+ORGL
> OK

Set master mode and check it:
AT+ROLE=1
> OK
AT+ROLE?
> +ROLE:1
> OK

Connect only to the specified bluetooth address:
AT+CMODE=0
> OK

Reset and initialize:
AT+RESET
> OK
AT+INIT
> OK

Configure inquiring mode:
AT+INQM=1,9,48
> OK

Inquire:
AT+INQ
> +INQ:12:34:567890:1F1F,7FFF
> OK
AT+STATE?
> +STATE:INQUIRING

Try to stop inquiring:
AT+INQC
> OK
AT+STATE?
> +STATE:INQUIRING
> OK

Reset and initialize again (otherwise we can't leave the inquiring state):
AT+RESET
> OK
AT+INIT
> OK
AT+STATE?
> +STATE:INITIALIZED
> OK

Try to pair with the found device (my PC asks for the 1234-password and creates a serial port):
AT+PAIR=12,34,567890,20
> OK
AT+STATE?
> +STATE:PAIRED

Try to connect
AT+BIND=12,34,567890
> OK
AT+LINK=12,34,567890
> FAIL
...

Does someone have some hints for finding the right sequence?

I am using a "BIND" between the Pair and Link:
AT+PAIR=98D3,31,FC2D54,5
AT+BIND=98D3,31,FC2D54
AT+LINK=98D3,31,FC2D54

I can't even pair... I'm trying to connect a ds4 with a hc-05. It seems the password is used to pair, but the ds4 doesn't have any. Any idea?

I had same problem and searched for several helps to make it, however a couple of solution I found in the net could not directly solve the problem.
Now I finally found the real solution ,thank to GOd!

It looks like I now have a slight understanding of what happens and how to get the HC-05 working.
Be sure to have the CMD-DAT-switch set to CMD before turning on the HC-05.
Command mode (configuration)
Check general AT command set:
AT
> OK

Reset to default values (sets, among others, ROLE=0 and CMODE=1):
AT+ORGL
> OK

Set master mode and check it:
AT+ROLE=1
> OK
AT+ROLE?
> +ROLE:1
> OK

Reset and initialize (reset aborts, e.g. the inquiring state - quickly flashing LED; without initializing you would get ERROR(16)):
AT+RESET
> OK
AT+INIT
> OK

Now the LED should slowly flash.
Optionally: set password of the target device:
AT+PSWD=1234
> OK

Show count of all authenticated devices in pair list:
AT+ADCN?
> +ADCN:7
> OK

If the value is larger than 0, delete all authenticated devices in pair list:
AT+RMAAD
> OK

Now pair with the desired device (the last 20 mean 20s):
AT+PAIR=12,34,567890,20
> OK

The LED starts flashing one time with a longer pause.
Set the desired device:
AT+BIND=12,34,567890
> OK

Now link (e.g. when connecting to the ELM327; the PC will create another new port after having requested the password from the user):
AT+LINK=12,34,567890
> OK

The LED starts flashing two times with a longer pause. After linking, it might be that either the HC-05 switches to data-mode or continues in command-mode (haven't found out when it does one or the other).
Command mode (auto connect)
Now switch off the HC-05 and keep the CMD-DAT-switch to CMD. Switch it on again. It should automatically connect to the previously connected device. To switch to the data mode, first disconnect...
AT+DISC
> +DISC:SUCCESS
> OK

... and reconnect.
AT+LINK=12,34,567890
> OK

Now the connection seems to have switched to data mode.
Data Mode
Now switch off the HC-05 and move the CMD-DAT-switch to DAT. Turn on the HC-05. It automatically will try to connect to the previously connected device - the LED should flash two times with longer pause - and you don't have to mess with HC-05-AT commands any more.

I am using a "BIND" between the PAIR and LINK:
AT+PAIR=98D3,31,FC2D54,5
AT+BIND=98D3,31,FC2D54
AT+LINK=98D3,31,FC2D54

That seems to work for me.
See the docs here:
ftp://imall.iteadstudio.com/Modules/IM120723009/DS_IM120723009.pdf


text:
How to use serial.read a sentences and serial.print after that enter to new line
This is my code but it doesn't work. I don't no why . I hope someone can explain the problem. Tks
unsigned char InTransfer;
char buffer;
void setup()
    {
  Serial.begin(9600);
}

void loop()
{
  /* when get the sentences and print it*/
   while ( Serial.available())
  {
    buffer=Serial.read();
    Serial.write(buffer);
    InTransfer=1;    // detect
  }
  /* After done enter one time */
  if (Serial.available()==0)
    if(InTransfer==1){
      Serial.println("");
      InTransfer=0;
  }
}

Can you provide more information? What doesn't work? Does it compile? What is it meant to do?

Your code works perfectly, I don't see a problem with it. It's doing exactly what you're telling it to.
The problem lies in a fundamental lack of understanding about how serial communications work on your part, so you are telling it to do the wrong thing.  Until you fix that aspect no program you try and write in this way will be a success.
You should start by learning how serial communication actually works.  A good starting point is an article I wrote ages ago: http://hacking.majenko.co.uk/reading-serial-on-the-arduino

Can u tell me how to fix this problem ? or give me an related example because I don't understand more. Thank you

@giangphuc Follow the link. Read the text.


text:
Arduino DUE Bossac Lockup after Ubuntu Upgrade
I already asked my question in the Arduino Forum here: https://forum.arduino.cc/index.php?topic=353846.0 but got no answer so far. Thus I hope here might be people who have a hint for me.
Since I introduced some Ubuntu patches I suspect these patches are to blame. But frankly I have no clue.
Here is what I got:
If I connect the programming port then Arduino IDE 1.6.5 properly recognizes it as the programming port. Thus I assume that the cable is properly plugged in and the Arduino powered. In addition I get
> lsusb
...
Bus 003 Device 019: ID 2341:003d Arduino SA
...

> dmesg
...
 2074.703747] usb 3-3: USB disconnect, device number 18
[ 2076.678150] usb 3-3: new full-speed USB device number 19 using xhci_hcd
[ 2076.696405] usb 3-3: New USB device found, idVendor=2341, idProduct=003d
[ 2076.696407] usb 3-3: New USB device strings: Mfr=1, Product=2, SerialNumber=220
[ 2076.696409] usb 3-3: Product: Arduino Due Prog. Port
[ 2076.696409] usb 3-3: Manufacturer: Arduino (www.arduino.cc)
[ 2076.696410] usb 3-3: SerialNumber: 55437333537351F0F1D0
[ 2076.696501] usb 3-3: ep 0x82 - rounding interval to 1024 microframes, ep desc says 2040 microframes
[ 2076.697270] cdc_acm 3-3:1.0: ttyACM3: USB ACM device
...

So I assume the device is definitely connected.
> ls -l /dev/ttyACM3
crw-rw---- 1 root dialout 166, 3 Okt 17 09:56 /dev/ttyACM3

> grep dialout /etc/group
dialout:x:20:udo

So I assume that my user "udo" is authorized to access the device. Everything as it should be and as it used to be.
The patches that were applied are:
> grep "2015-10-16.* upgrade " /var/log/dpkg.log
2015-10-16 09:25:29 upgrade udev:amd64 204-5ubuntu20.14 204-5ubuntu20.15
2015-10-16 09:25:30 upgrade libudev1:amd64 204-5ubuntu20.14 204-5ubuntu20.15
2015-10-16 09:25:31 upgrade libpam-systemd:amd64 204-5ubuntu20.14 204-5ubuntu20.15
2015-10-16 09:25:32 upgrade systemd-services:amd64 204-5ubuntu20.14 204-5ubuntu20.15
2015-10-16 09:25:32 upgrade libsystemd-daemon0:amd64 204-5ubuntu20.14 204-5ubuntu20.15
2015-10-16 09:25:33 upgrade libsystemd-login0:amd64 204-5ubuntu20.14 204-5ubuntu20.15
2015-10-16 09:25:34 upgrade chromium-codecs-ffmpeg-extra:amd64 45.0.2454.85-0ubuntu0.14.04.1.1097 45.0.2454.101-0ubuntu0.14.04.1.1099
2015-10-16 09:25:35 upgrade libgdk-pixbuf2.0-0:amd64 2.30.7-0ubuntu1.1 2.30.7-0ubuntu1.2
2015-10-16 09:25:35 upgrade libgdk-pixbuf2.0-common:all 2.30.7-0ubuntu1.1 2.30.7-0ubuntu1.2
2015-10-16 09:25:36 upgrade google-chrome-stable:amd64 45.0.2454.101-1 46.0.2490.71-1
2015-10-16 09:25:41 upgrade libgl1-mesa-dri:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5
2015-10-16 09:25:42 upgrade libgbm1:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5
2015-10-16 09:25:43 upgrade libgl1-mesa-dev:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5
2015-10-16 09:25:43 upgrade mesa-common-dev:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5
2015-10-16 09:25:44 upgrade libgl1-mesa-glx:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5
2015-10-16 09:25:45 upgrade libgles2-mesa:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5
2015-10-16 09:25:45 upgrade libwayland-egl1-mesa:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5
2015-10-16 09:25:46 upgrade libegl1-mesa-drivers:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5
2015-10-16 09:25:47 upgrade libglapi-mesa:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5
2015-10-16 09:25:48 upgrade libopenvg1-mesa:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5
2015-10-16 09:25:48 upgrade libegl1-mesa:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5
2015-10-16 09:25:49 upgrade libgudev-1.0-0:amd64 1:204-5ubuntu20.14 1:204-5ubuntu20.15
2015-10-16 09:25:50 upgrade libhunspell-1.3-0:amd64 1.3.2-6ubuntu2 1.3.2-6ubuntu2.1
2015-10-16 09:25:51 upgrade libspice-server1:amd64 0.12.4-0nocelt2ubuntu1.1 0.12.4-0nocelt2ubuntu1.2
2015-10-16 09:25:51 upgrade libxatracker2:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5
2015-10-16 09:25:52 upgrade linux-image-3.13.0-65-generic:amd64 3.13.0-65.105 3.13.0-65.106
2015-10-16 09:25:55 upgrade libsystemd-journal0:amd64 204-5ubuntu20.14 204-5ubuntu20.15
2015-10-16 09:25:55 upgrade ubuntu-release-upgrader-gtk:all 1:0.220.7 1:0.220.8
2015-10-16 09:25:56 upgrade ubuntu-release-upgrader-core:all 1:0.220.7 1:0.220.8
2015-10-16 09:25:57 upgrade python3-distupgrade:all 1:0.220.7 1:0.220.8
2015-10-16 09:25:58 upgrade update-manager:all 1:0.196.13 1:0.196.14
2015-10-16 09:25:59 upgrade update-manager-core:all 1:0.196.13 1:0.196.14
2015-10-16 09:26:00 upgrade python3-update-manager:all 1:0.196.13 1:0.196.14
2015-10-16 09:26:01 upgrade firefox:amd64 41.0+build3-0ubuntu0.14.04.1 41.0.1+build2-0ubuntu0.14.04.1
2015-10-16 09:26:04 upgrade firefox-locale-en:amd64 41.0+build3-0ubuntu0.14.04.1 41.0.1+build2-0ubuntu0.14.04.1
2015-10-16 09:26:05 upgrade flashplugin-installer:amd64 11.2.202.521ubuntu0.14.04.1 11.2.202.535ubuntu0.14.04.1
2015-10-16 09:26:06 upgrade gir1.2-gdkpixbuf-2.0:amd64 2.30.7-0ubuntu1.1 2.30.7-0ubuntu1.2
2015-10-16 09:26:06 upgrade gir1.2-gudev-1.0:amd64 1:204-5ubuntu20.14 1:204-5ubuntu20.15
2015-10-16 09:26:07 upgrade linux-headers-3.13.0-65:all 3.13.0-65.105 3.13.0-65.106
2015-10-16 09:26:12 upgrade linux-headers-3.13.0-65-generic:amd64 3.13.0-65.105 3.13.0-65.106
2015-10-16 09:26:15 upgrade linux-image-extra-3.13.0-65-generic:amd64 3.13.0-65.105 3.13.0-65.106
2015-10-16 09:26:21 upgrade linux-libc-dev:amd64 3.13.0-65.105 3.13.0-65.106
2015-10-16 09:26:22 upgrade thunderbird-locale-en:amd64 1:38.2.0+build1-0ubuntu0.14.04.1 1:38.3.0+build1-0ubuntu0.14.04.1
2015-10-16 09:26:23 upgrade thunderbird:amd64 1:38.2.0+build1-0ubuntu0.14.04.1 1:38.3.0+build1-0ubuntu0.14.04.1
2015-10-16 09:26:26 upgrade thunderbird-gnome-support:amd64 1:38.2.0+build1-0ubuntu0.14.04.1 1:38.3.0+build1-0ubuntu0.14.04.1
2015-10-16 09:26:27 upgrade thunderbird-locale-en-us:all 1:38.2.0+build1-0ubuntu0.14.04.1 1:38.3.0+build1-0ubuntu0.14.04.1
2015-10-16 09:26:27 upgrade liboxideqt-qmlplugin:amd64 1.9.1-0ubuntu0.14.04.2 1.9.5-0ubuntu0.14.04.1
2015-10-16 09:26:29 upgrade liboxideqtquick0:amd64 1.9.1-0ubuntu0.14.04.2 1.9.5-0ubuntu0.14.04.1
2015-10-16 09:26:30 upgrade liboxideqtcore0:amd64 1.9.1-0ubuntu0.14.04.2 1.9.5-0ubuntu0.14.04.1
2015-10-16 09:26:33 upgrade oxideqt-codecs-extra:amd64 1.9.1-0ubuntu0.14.04.2 1.9.5-0ubuntu0.14.04.1
2015-10-16 09:26:33 upgrade python-tz:all 2012c-1build1 2012c-1ubuntu0.1

I checked with Arduino 1.6.0 (which worked till yesterday) and then installed Arduino 1.6.5. Arduino 1.6.5 also fails to upload but definitely recognizes the port. What I get though is the message "Forcing reset using 1200bps open/close on port /dev/ttyACM3..." and then the upload is stuck. To be more precise bossac gets stuck and puts 100% load on one of my cores.
I also installed bossash. If I issue a "scan" command bossash will properly detect the correct port. However I will also lockup with 100% load on one of the cores. So the issue is probably not related to the IDE at all but to bossa.
Has anyone a hint how I might fix this? That is why bossac lock up and how to get it to upload again as it did before?


text:
How can I enable the security bit of a teensy board?
I want to prevent someone from connecting an arduino device to a computer and downloading the code (yes, the hex-dump code) because I want to embed a wifi password inside a device that should be kept secret
With that said, I stumbled upon this answer that mentions a security bit
I would like to ask for more details regarding it - i.e. how can I use it, enable it, what are it's limitations, etc. (Preferably for a Teensy v3.2 board, but if it's standard/generic, I would accept such an answer as well).

It is neither standard nor generic.

@IgnacioVazquez-Abrams then id like a Teensy v3.2 solution if possible

Given that the controllers in question don't have on-chip wifi, it is likely that the wifi credentials are going to be sent in the clear across some sort of standard serial interface to the wifi engine, and can be sniffed in flight.  So read-locking the MCU won't actually achieve your goal.

@ChrisStratton you would be correct, I do intend to eventually make this on my own PCB though and thus sniffing them from the serial interface would be difficult if not impossible without de-soldering the chip(s) - although I think at that point I may as well go with storing them on an embedded SD card or similar as well (yes, one could still write a program to read it from the SD card, after downloading the current code to see where to look on the SD card, and then publish it via the wifi somehow, but that is becoming a complicated procedure).

Unless you are using all BGA chips and routing only on internal layers, it doesn't really follow that a custom PCB prevents sniffing.  Those Cypress FX2 logic analyzers are cheap, powerful, and frequently employed for this type of purpose (for example, reversing propriety 2.4 GHz RC toy protocols to allow using a transmitter with better sticks)

@ChrisStratton I was thinking of potting (i.e. covering in epoxy) the sensitive area between the processor/storage/wifi, but leaving the USB and some other stuff exposed - should make it difficult if not impossible to use any sort of logic analyzer on that area of the PCB without destroying the PCB physically

The Teensy 3.2 board is based on MK20DX256. The processor core is an ARM and not AVR. The best way to learn about security on the MK20DX256 is to read the documentation.

Chapter 8 Security
  8.1 Introduction
  This device implements security based on the mode selected from the flash module. The following sections provide an overview of flash security and details the effects of security on non-flash modules.
8.2 Flash Security
  The flash module provides security information to the MCU based on the state held by the FSEC[SEC] bits. The MCU, in turn, confirms the security request and limits access to flash resources. During reset, the flash module initializes the FSEC register using data read from the security byte of the flash configuration field.
NOTE The security features apply only to external accesses: debug and
  EzPort. CPU accesses to the flash are not affected by the status
  of FSEC. In the unsecured state all flash commands are available to the programming interfaces (JTAG and EzPort), as well as user code execution of Flash Controller commands. When the flash is secured (FSEC[SEC] = 00, 01, or 11), programmer interfaces are only allowed to launch mass erase operations and have no access to memory locations.
Further information regarding the flash security options and enabling/disabling flash security is available in the Flash Memory Module.

The next step is to search for an open-source project that uses the FSEC setting. And by chance the mbed does. Here is link to how it is done in the mbed CMSIS Cortex-M4 Core Device Startup File for the MK20DX256. There should be the same setting in the Teensy Arduino core. Locating that is left to the reader.
Cheers!

It is possible for the AtMega processors - like the Teensy 2.0 (see https://www.pjrc.com/teensy/ ).
Steps:

Work out your exact code. It will be a pain to update it once this is done, so thing carefully.
Upload the code using ICSP (file->upload using programmer). TEST IT HERE!
Work out the fuse you need to set. The important one is "RSTDISBL" - this disables the reset pin (makes it behave just like a regular pin).  Use the page at http://www.engbedded.com/fusecalc/ to calculate your fuse settings.
DOUBLE CHECK IT!
Use an ICSP to set the fuse. You will need to work out the 6 pins to connect the ICSP to, since there is no standard ICSP header.

If you did everything right, and the reset pin no longer works - this will protect the code from download!
If anything went wrong (e.g. you set the wrong fuse values - I've been there), or if you want to change the code, you will run into problems. In theory, you can use a high-voltage programmer - like http://www.societyofrobots.com/member_tutorials/node/239 - to reset everything to factory, but that takes 20 volts, and there's a high chance one of the other components on the Teensy board will be damaged.
Note that, if you do use the High-voltage programmer, the chip's memory will be wiped, so this can't be used to recover your code.

Any thoughts for the arm versions?

It's only 12V (on the pin), and it's not difficult to build a HV programmer.

This is not only targeting the wrong chip (the Teensy 3.x are NOT ATmegas), it is bad advice - the goal is to prevent readback which is a distinct goal from blocking the (re)programming pins.

The reprogramming pins are enough to read back the data. It's not difficult to build an HV, but that doesn't get you the data, only lets you wipe it. I missed the bit where it said v3.2, and I believe the "security bit" mentioned in the link in the question is the method I described.

You are overlooking the difference between disabling the pins vs disabling readback.  Typically, when you lock a chip you can still reprogram it via the most convenient method (if you are willing to erase it), but what you cannot do is read back the existing memory.

While this does not answer your question, I believe it may help you with an alternative approach, which won't hide it completely, but will make it a lot harder to figure out.
Rather than keeping the password in plain text (which will be easy to spot in a hex dump), you can hide it somewhat. For example, exclusive-or each byte of the password with a randomly chosen number, put the result in your code; then, when you want to log in to the wifi, exlusive-or it with the same numbers (which must also be on your code).
Note that all the information required MUST be on the Teensy, so it is not impossible to reverse engineer; however, it will be hidden from casual inspection.
Note that, although more complex obfustication is possible (using any off-the-shelf encryption), since both the code and any keys will be available to an attacker, it is a token gesture only.
The Teensy v3 has JTAG, which means a running Teensy can be inspected, single-stepped, all memory and pin states can be viewed & modified. Once someone has your device, it's pretty much a lost cause against a determined attacker.

The Teensy (or at least the primary MCU used on it) can of course be read-secured which should make the jtag access irrelevant; what you miss is that the credentials can still be sniffed in-flight to the wifi engine.

@ChrisStratton, since you seem to know the answer to this question, could you post it as an answer (with the caveat that it won't work in this case)? That way, if someone else finds this question and wants it for a different purpose, they don't have to ask a new question?


text:
Communicating Arduino with Intel Galileo
I'm doing a project where I have few sensors on Arduino Uno. Now I am trying to send some data to the internet where i figured using my GSM shield with the Galileo board I have is the best solution.
The problem I am facing is that software serial is not working on Galileo so I have to use the Serial1 of Galileo board (Pin 0 and Pin 1) and I am out of serial ports. I was thinking of using serial communication between Arduino and Galileo but Galileo seems to have only pin0 and pin1 as serial and they are occupied by the GSM shield.
Is there any part I am getting wrong or any suggestions?
(other than using the sensors on Galileo and getting rid of the Arduino Uno :) )

What is wrong with getting rid of the UNO and using only the Galileo?
It seems anyway the easier solution even from debugging perspective.

Well I am using some sensors that has AVR specific libraries and many complex codes depending to them which would be taking much time trying to migrate to Galileo.

You could use SPI/I2C as interface between Arduino and Galileo.
They are better than plain serial.

I have started using I2C as you suggested. Thank you!


text:
Relay module and internal pull-up resistors
I'm currently assembling a prototype of the lightning infrastructure (based on several MEGAs interconnected via RS485, as described in this other post)
The prototype consists of three MEGAs, a couple of wall-push-button and the two relay modules here below:

250V 2A 8 Channel OMRON SSR G3MB-202P Solid State Relay Module For Arduino
5V 4 CH OMRON SSR G3MB-202P Solid Relay Module with Resistive Fuse For Arduino

Obviously I've:

connected one endpoint of each push-buttons to Arduino INPUT-PIN; the other endpoint to ground;
connected the relay-module control-pins to Arduino OUTPUT-PIN (and ensuring a properly connected ground).
connected lamps to relay-modules power connectors.

My question relates to "pull-up resistor": I've read in lots of places that when involving push-buttons, "pull-up resistors" are needed in order to prevent shorts between ground and input-pin. As such, there are lots of tutorial/videos on the web, showing a nice resistor added in the push-button circuit.
Further investigating, I've also learnt from the official documentation that "...There are 20K pullup resistors built into the Atmega chip that can be accessed from software....", by setting the pinMode() as INPUT_PULLUP or setting it to INPUT and the forcing a digitalWrite(<PIN>,HIGH).
So, I ended:

directly connecting the two relay-modules to MEGAs INPUT-PINs and...
...activating the internal pull-up, with digitalWrite(<INPUT_PIN>,HIGH);

Nothing more.
This is the second evening I'm "testing" my Arduino-luggage-prototype and... lamps are turning on/off like a charm, without any noticeable problem.
The question is: am I doing something nasty toward my MEGAs? Is the approach depicted above, a commonly-safe (as for the Arduino's health) approach?

P.S.: should you wonder about how the prototype looks like, here is a photo (actually, taken right after the first power-up ;-)

Connecting one side of a switch to ground and the other side to an input pin (with its pinmode set to INPUT_PULLUP) is a standard way of connecting control switches to an Arduino installation, and is not a problem.
Note, claims that built-in pull-ups are 20KΩ oversimplifies the situation.  See, for example, Table 28.2, DC Characteristics, in the ATmega48PA/88PA/168PA/328P specs, which shows a min value of 20KΩ for   I/O Pin Pull-up Resistors and a max value of 50KΩ.  I've measured resistances of about 40KΩ, IIRC, whenever I've measured the pull-up values.
Note, built-in pull-ups typically are of too much resistance to work as pull-ups for TWI/SPI/I2C communications.
Note, when you say in the question that you connected the relay-modules to input pins and they worked ok, I suppose that could be the case, but in general it is better to put i/o pins into output mode when you want to drive an output.  When you send LOW to an input pin, its built-in pull-up is turned off, the input impedance becomes high, and then the pin can float to any value between ground and Vcc. It might fail to turn off an attached device if that device also has high impedance.

As for the connection of relay-modules, I'm sorry! It's a typo (that I've just fixed): relay modules are driven by OUTPUT pins. Not input.

I am making the assumption the push buttons are wired directly to the mega.  This may work but for me it is not acceptable.  Why?  All of those wires act as an antenna array tuned to a lot of different frequencies.  My favorite trick is to use a 74C14 Schmidt trigger chip.  The reason is several fold. First it isolates the antennas from the processor.  The family I use will tolerate about 25volts input, giving a lot of head room.  Second it makes the software a bit easier, all switches come in positive true. Third I use a low pass network in front so if one of the mains hits it it will probably survive.  What I do is Pull up with a resistor that will cause about 1.5 ma to flow through the switch.  This value is dependent on your voltage, I typically use 12 or  24 VDC.  This input then goes through a 100K resistor to the input of the gate where I also put a .01 uF cap.
I am also working on a similar project, I made the same decision on a hardwired network about 15 years ago.  All the switching is on several output boards (5V) located in a PC AT. I also chose the mega for several reasons, first I needed full duplex with my network, the MAX485 will do that you just have to leave the receive enabled and cycle the transmit when you want to send something.  I also added a low pass on the (A line I Think) to another pin so I could determine if the network was busy,  I currently have about 150 outputs with very few inputs.  Code is all in ASM86.
I hope this helps, I will see if I can add to your reference question.
Thanks,
Gil


text:
Help with arduino car project
So in computer engineering I've got to make a arduino based car, I've added a whole bunch of features such as IR tracking, obstacle avoidance(proximity sensor), optical tracking(follow a black line), and remote control through an android based phone.
Since I'm a total newbie to technology I'm having trouble. I would appreciate it if You guys can point me towards resources and arduino libraries(for coding) that will work for me. Right now for coding I've only got basic pseudo-code setup since I do not know what libraries to use. I have searched up many sketches online and looked at them but didn't really understand any of the code.
Here's the basic pseudo-code I got setup on the things that I've got to work on:
DC Motor (4 of em for the wheels) (I also plan to add a stepper motor for turning right and left so if you could direct me on that as well)
//Import necessary library
//Setup the motors and pins
//If signal for forward received
//Code for moving forward
//Set speed
//Else If signal for backward received
//Code for moving backward
//Set speed
//Else If signal for right received (keep turning right till stop signal received)
//Code for moving right
//Set speed
//Else If signal for left received (keep turning left till stop signal received)
//Code for moving left
//Set speed
//Else If signal for stop is received (Should we slow down to a stop or just stop?)
//Code for stop
//Set speed
IR (I've got transmitting and recording diodes)
//Import Library
//Declare Pin for the IR Sensor
//While loop: Move Right
//If IR signal is received
//move forward
//Else
//Jump back to top of loop
Proximity Sensor (obstacle avoidance mode) (I might either use the one from Lego kit or buy a separate one )
//Import Library
//Declare Pin for proximity sensor
//While Loop: Send out sonar(echolocation or whatever) every second
//Is there any obstacle?
  //Yes, turn right so many degrees, and go back to while loop
  //No, move on forward at set speed
//If you’re surrounded and cannot exit send out a message through flashing LED's

I'm not asking for the code or for any of you to do all my stuff for me, I'm just asking for direction and resources.
Thank You

1) start simple - adding extra features will not help you, especially if you have a deadline
2) implement and test code for each low level function separately - however, in case you use libraries and or snippets, make sure that if a library/snippet requires exclusive use of a certain feature (ex: a timer), others do not need it.
3) test the overall logic elsewhere, where it easier to debug (ex: on a PC), by replacing the actual function calls to low level actuators/sensors with mockup functions that do I/O through either a file or a console.
Said this, what do you mean that you didn't understand the examples you found? To understand most of them, you need at least to read the API/interface of the libraries they use. And also reading the reference manual of the ATMega328P for the HW blocks referred by each library will help getting an overall feeling of what the library does.
About the basic physical model: once you have 4 DC motors (but 2 plus a caster would be enough), why do you want to add a stepper? Youc could do all of it with just 2 stepper motors , which will give you a simpler way to control precisely the orientation of the robot.
I'd suggest you to get the basic movement sorted out, before worrying about the rest. Just make sure that it doesn't make exclusive use of the microcontroller.


text:
Raspberry Pi, Teensy and Arduino's on i2c
I just got into an interesting mess.
I have 3 Arduino's (Pro Mini's) and 2x Teensy's (3.1's) connected via I2C to a Raspberry Pi Master. The 2x Teensy's I2C data lines are connected via OctoBoards but that doesn't really matter since the OctoBoard maps the I2C Pin's of the Teensy to itself. I have 4k7 pullup resistors for SDA/SLC close to the master (also tried on the end - with no effect).
The Arduino's alone are super solid - no issues other than the occasionally I2C lockup when writing data.

The I2C interface has been running for over 3h with no problems.
Now as soon I add a Teensy to it, the bus locks-up and I need to completely shut down everything. Only thing I got to work was direct connection from RPI -> Teensy and even then there were sporadic detection issues.
I tried the Wire lib as well the IC2_T3 lib with no difference. Also tried with 4 different Teensy's with no difference.
Are the Teensy's not compatible with RPI?

That is a lot of antenna hanging around.  Consider using a method that keeps the Microprocessor wires from going from computer to computer.  Ground references could cause a lot of problems and would explain the problems but it is not the only possibility.  Different processors have different reactions to transients.  Be sure the grounds from each unit are connected together.  I would expect each combination to act differently.

I do not have experience with your exact setup, but I once had a similar problem. I had a pi as I2C master, a battery module that used I2C to communicate battery status and two servo controllers attached. The servo controllers alone worked and the battery module alone worked, but all three attached to the pi didn't work and there was no collision in I2C addresses (have you checked that btw?). It turns out, that both servomodules and the battery module had I2C pullup resistors attached, so the end result was 3x4k7 in parallel, which is around 1566 ohm. The solution was to remove the pullup resistors from the servo controllers.
So the question is, have you by any chance enabled pullup resistors on any of the arduinos/teensys/pi in addition to your own resistors, resulting in wrong pullup resistor value?


text:
A whole basic game project Arduino
Firstly, I know that I have already posted this. I do not think anyone here is stupid so:
The game is: a power source connected to 6 buttons connected to 6 LEDs. you press them all in the randomly generated order, and they blink in the order pressed after completion, then randomize and reset.
I have an array shuffler code  1)Does the array shuffler work 2)How do I configure ports and attach them to values in the array, 3) How do I use an if-then statement to say if all buttons pressed in order, then LEDs blink 3 times?  I have a picture but not the actual Arduino, so, upon request, I can post the picture. Thank you. code:
void setup() {
    // put your setup code here, to run once:
}

void loop() {
    // put your main code here, to run repeatedly:
    int questionNumberArray[] = {0,1,2,3,4,5,6};//the array itself
    const size_t n = sizeof(questionNumberArray) / //the array used
    sizeof(questionNumberArray[0]);//the base of the array

    for (size_t i = 0; i < n - 1; i++) //the loop itself
    {
        size_t j = random(1, n - i);
        int t = questionNumberArray[i]; //integer output for increase
        questionNumberArray[i] = questionNumberArray[j];//the value definition
        questionNumberArray[j] = t;
    }

}

The six buttons are connected to digital pins (1, 2, 9, 11, 12, 13)

If you've already posted this, why have you posted it again? It won't get answered any quicker.

Possible duplicate of array shuffler if-then and output question

Yes, this version is just much more organized so...I figured people would be more inclined to answer it

my arduino's ports are 1, 2, 9, 11, 12, and 13. for me to link to them at the top of the code how would I distinguish between all the different PinB's. also, they would be pins, not ports right, since there needs to be detection of the button being pressed?

What pins are the 6 buttons connected to?

@Chris ports 1, 2, 9, 11, 12, and 13

I assumed those were for the leds. What pins are the leds on then?

@Chris same. power connects to ports which connects to buttons which then connect to LEDs

The leds need to be connected to some pins in order for the arduino to turn them on and off. Can you upload a picture of the schematic you are using? You can download and make a schematic with a breadboard with fritzing. It's free here: http://fritzing.org/download/

this version is just much more organized so - you know you can edit your original question, right?

So you leds are connected to "pins" not "ports." Since each of the buttons will turn on only 1 led we need to keep track of which button pairs with which led. To do this we can use a struct like this one:
struct ButtonLed{
        int buttonPin;
        int ledPin;
};

You declare a ButtonLed like this: ButtonLed button1 = {1, 0} where the first parameter is the button's pin and the second is the led's pin. (All of the led pins are set to 0 since I don't know which pins you have them connected to.)
And the array will hold the button/led pin pair like this:
ButtonLed questionNumberArray[] = {button1, button2, button3, button4, button5, button6};
Since there are 6 leds you know that your array is size 6 so use this declaration instead
const int n = 6;
I fixed you range for the random number generation. Look at the documentation for random() here https://www.arduino.cc/en/Reference/Random. We can use this function for shuffling the array.
void shuffleArray (ButtonLed arr [], const int size){
    for (int i = 0; i < size - 1; i++){ // iterates through array except last element
        int j = random(0, size); // generates a random index from (0 to n-1) inclusive

        // swap current index with random index
        ButtonLed t = arr[i];
        arr[i] = arr[j];
        arr[j] = t;
    }
}

We will use this function to wait until the user enters a sequence of button presses:
ButtonLed getButtonPress (ButtonLed arr [], const int size){
    bool pressed = false;
    ButtonLed  pressedButton;
    while (!pressed){ // loops until a button was pressed
        for (int i = 0; i < size && !pressed; i++){ // !pressed allows early out
            if (digitalRead(arr[i].buttonPin)){ // one of the six buttons was pressed
                pressed = true; // exit both loops
                pressedButton = arr[i]; // stores which button was pressed
            }
        }
    }
    return pressedButton; // return the pressed button
}

Essentially it gets stuck in a loop and reads each of the 6 buttons until one of them is pressed and then records which one was pressed.
Try using the code below and read the comments the only thing you need to do is change all the zeros in the ButtonLed declarations to whatever pin the leds are connected to. Also the struct above needs to go into it's only file called "ButtonLed.h" It must be called that.
#include "ButtonLed.h"

// These are ButtonLeds our newly created data type
// they hold both an led's pin and the pin for the button
// that turns it on
ButtonLed button1 = {1, 10};
ButtonLed button2 = {2,  8};
ButtonLed button3 = {9,  7};
ButtonLed button4 = {11, 6};
ButtonLed button5 = {12, 5};
ButtonLed button6 = {13, 4};

// This function will randomly shuffle an array of ButtonLeds
void shuffleArray (ButtonLed arr [], const int size){
    for (int i = 0; i < size - 1; i++){ // iterates through array except last element
        int j = random(0, size); // generates a random index from (0 to size-1) inclusive

        // swap current index with random index
        ButtonLed t = arr[i];
        arr[i] = arr[j];
        arr[j] = t;
    }
}

ButtonLed getButtonPress (ButtonLed arr [], const int size){
    bool pressed = false;
    ButtonLed  pressedButton;
    while (!pressed){ // loops until a button was pressed
        for (int i = 0; i < size && !pressed; i++){ // !pressed allows early out
            if (digitalRead(arr[i].buttonPin)){ // one of the six buttons was pressed
                digitalWrite(digitalRead(arr[i].ledPin, HIGH); // turns on the led the user chose
                delay(200);
                digitalWrite(digitalRead(arr[i].ledPin, LOW); // turns it back off
                pressed = true; // exit both loops
                pressedButton = arr[i]; // stores which button was pressed
            }
        }
    }
    return pressedButton; // return the pressed button
}

void setup() {
    randomSeed(analogRead(A0));
    // This is how you set up the leds for output
    pinMode(button1.ledPin, OUTPUT);
    pinMode(button2.ledPin, OUTPUT);
    pinMode(button3.ledPin, OUTPUT);
    pinMode(button4.ledPin, OUTPUT);
    pinMode(button5.ledPin, OUTPUT);
    pinMode(button6.ledPin, OUTPUT);

    // This is how you set up the buttons for input
    pinMode(button1.buttonPin, INPUT);
    pinMode(button2.buttonPin, INPUT);
    pinMode(button3.buttonPin, INPUT);
    pinMode(button4.buttonPin, INPUT);
    pinMode(button5.buttonPin, INPUT);
    pinMode(button6.buttonPin, INPUT);
}

void loop() {

    // This array is of type ButtonLed our newly created data type
    ButtonLed questionNumberArray[] = {button1, button2, button3,
                                       button4, button5, button6};
    const size_t n = 6; // array's size

    shuffleArray(questionNumberArray, n);

    numLeds = 1;
    bool guessCorrectly = false;

    // this while loop allows the user to keep trying until they get it right
    while (!guessCorrectly){

        // This loop displays the correct sequence to the user
        for (int i = 0; i < numLeds; i++){
            digitalWrite(questionNumberArray[i].ledPin, HIGH); // turn on the led

            delay(500); // decrease this number to flash faster; increase to flash slower

            digitalWrite(questionNumberArray[i].ledPin, LOW); // turn off the led
        }

        bool correctButton = true; // the user has pressed the correct button
        ButtonLed userSequence [6];      // stores the sequence the user entered
        // lets the user push 6 buttons
        for (int i = 0; i < numLeds; i++){
            userSequence[i] = getButtonPress(questionNumberArray, numLeds);
            delay(500); // delay between button presses
        }

        // check if the user entered the correct sequence
        for (int i = 0; i < numLeds && correctButton; i++){
            if (userSequence[i].buttonPin != questionNumberArray[i].buttonPin)
                correctButton = false;
        }

        if (correctButton){ // user entered the correct sequence
            guessCorrectly = true;
            // This will turn on the leds in the correct sequence
            for (int i = 0; i < numLeds; i++){
                digitalWrite(questionNumberArray[i].ledPin, HIGH); // turn on the led
                delay(500); // delay half a second
                digitalWrite(questionNumberArray[i].ledPin, LOW); // turn off the led
            }
            numLeds++;
            if (numLeds > 6)
                --numLeds;
        }
    }
}

After you are finished typing the code above it ctrl+shift+n and open a new tab called "ButtonLed.h" and add this to it:
#ifndef BUTTONLED_H
#define BUTTONLED_H
#include <Arduino.h>

// We create new data type called ButtonLed which stores the button's pin
    // and the led's pin; this allows us to keep both an led and it's
    // corresponding button together without have to manage 2 arrays
    struct ButtonLed{
        int buttonPin;
        int ledPin;
    };

#endif

Make sure you open a new tab and not a new project. Also as others have said you should really learn how to program. Be aware this code compiles however, I haven't tested it. I will update the code when you tell me what pins the leds are connected to.
Edit 1
I added a while loop that allows the user to keep trying until they guess correctly.
Edit 2
I also updated the code for which pins the leds are connected to. Remember they're connected to "pins" Not "ports.

The arduino looks like this: http://postimg.org/image/j65d4jd6b/59b97e93/

how do I choose an answer

how do i choose an answer, and what are the ports of the buttonLEDs in relation to the picture? They are hitting multiple points, how do I know which to use?

Ok so the way your arduino is set up right now won't work. This is because none of the leds are connected to the Arduino's pins. I have added a picture of a schematic to my answer. You must replicate the schematic exactly in order for it to work with the code. Also what do you mean by "choose an answer"? Do you mean "how do you guess a sequence?" or "how do you choose a sequence for someone else to guess?"

i mean literally the buttons are in place. to replace the zeros, which number do I put for each?

wait...where's the schematic?

Reload the page there's a picture at the end of the answer, also I've updated the code to replace the zeros. However, you have to connect the leds to the digital pins for it to work. You need to change the way your buttons are connected in order for them to work with the code. Did you want the leds to flash in order and then the user must remember that order?

Let us continue this discussion in chat.


text:
How to program an offbrand arduino uno?
So I recently bought this off brand arduino uno from betemcu.cn.
it says its r3 compatible.
Can I program this thing with the arduino coder or do I need to use something else? whenever I try uploading the code it says "problem uploading to board"
what settings or program should I use to code this?

Ask betemcu.cn for docs?

You installed the serial driver, right?

Try uploading program using ICSP.!

Have you tried changing the type of board in the Arduino interface ? For your board I would try the Arduino Uno setting. Also check that the correct serial port is selected (yes I know you connect via USB, it's a virtual COM port I'm talking about).

The issue is probably that you need a driver for the onboard CH340G USB-to-serial bridge.
The Baite Electronics Arduino clones are generally of good quality and work well.
There are some differences between them and Arduino-brand Arduinos. Two notable ones are a different voltage regulator and (probably the issue here) a different USB-to-serial bridge IC.  The Arduino brand products use an FTDI IC and Baite uses, in this case, the CH340 USB bridge IC.
The product is described on this webpage and you will see that they say

UNO MEGA328P CH340G for Arduino Compatible

The CH340G relates to the USB interface IC.
Until about a year ago the USB driver in windows worked with most common USB ICs as well as with FTDI ICs.  However, FTDI changed their system so that the Windows driver will now only work with FTDI brand ICs. So it is now necessary to load a driver into the PC (whether Windows, Linux or other O/S) to suit the CH340.
If you email them Baite will provide a link to the CH340 driver, but they do not usually provide it on their website (reason unknown to me.)
Or, you can obtain a driver from numerous websites.
A web search on eg:  driver ch340 baite arduino
turns up many pages.   How good or how safe any of these is is TBD.
This page claims to provide a Windows 7 CH340G driver and install instructions
This YouTube video describes how to install a driver and provides a link to this page which lists a number of drivers.
This page discusses the issue

betemcu.cn/Baite (is there a difference?) should pay you for offering support on their products!

@RespawnedFluff I know you've heard me say it before but, for others: I have no relationship with Baite except as a satisfied customer. I've bought a few orders from them - maybe $200 overall more or less. I've been happy with the product, the price and the responsiveness. Their documentation is essentially nonexistent - which seems strange considering how easy it would be to provide basic data. Even the driver non provision is strange - they will provide (afair) a temporary link if you ask (which I did at one stage). I have heard various tales about Arduino clones which work poorly  ....

.... or not at all or are of generally low quality or poorly made. Anything I've bought from them (that has actually got used :-) ) has worked as expected. Others' experiences with them may be different and I have no involvement whatsoever in their dealings with anyone except me.

@RespawnedFluff Re Baite/Bete - the photos that Corey supplied seem to be an essentially exact match for the ones on their website and the PCB silkscreen contains both Baite as a company name and betemcu.cn as a website. So one and the same it seems.

Re: "I know you've heard me say it before". Actually, I haven't. And I didn't mean to sound like you were dishonest, hiding something, or anything remotely dubious like that. I'm sorry if I came across that way, and I probably did given the length of your reply. Cheers.

@RespawnedFluff No - no problem - I just talk too much :-). You raised a valid point which I thought was worth addressing for others. I usually add some sort of disclaimer in such posts but didn't do soon that occasion - my bad.

Just install your driver. Some might install automatically. Then try to upload the sketch using arduino IDE.


text:
How to Store the Value of A Sr04 Ultrasonic distance sensor (ping)?
I am using a Sr04 Ultrasonic distance sensor with Uno clone for making a Alarm. The basic idea behind this project is that In Setup, Read the distance And store it in a varibale as Threshold. And in Loop, Check the distance readings regularly and if the Reading anytime is not equal to The threshold (that means someone interrupted in front of ultrasonic sensor), then a led flashes. I Know that is system is not enough good because the real world is a bit noisy. My problem is I am storing the theshold distance in "int" variable. The compiling error is "Cant convert Long Unsigned char to Int" something like this. Please tell me how can I store the reading of my sr04 sensor in a variable. I am using NewPing Library.

First you must verify that storing the value as int is even possible: long int can represent much larger values than int. Are you 100% sure that the maximum reading you will ever get can be represented as int?
In case the answer to the previous question is "yes", then you can just cast it on the fly:
int int_val = (int)function_returning_longint();
In case the answer is "no", you can either give up the idea of using int and stick with long, which is not necessarily bad, or you can scale down the value, at the price of loosing some resolution:
int int_val = function_returning_longint() >> 8; This assumes that long is 16 bit and int is 8 bit, but it would be preferable to use explicit types, like int8_t and int16_t. And in your case you might have to shift by a different value than 8.

Either way, do not make casts of from big type to small type without being 100% sure that the max value you will ever deal with can fit in the small type.

If you want to store it as int, you have to firstly store it in a long type then convert it into int.
For instance:
long i;
int j;
i = getReading();
j = (int) i;

There are many ways to do it, for example you can also use rounding to convert it into integer variable.

It's not necessary to use an auxiliary variable.
But what is really dangerous in this answer, is that it doesn't check if the value is small enough to be represented as int.


text:
Loop completion and resetting
Alright, so this code is for a game that is a power source connected to 6 buttons at ports 1, 2, 9, 11, 12, and 13. These are consequently supposed to light up 6 LEDs, each connected to 1. If you press the buttons in the right order, all the LEDs blink at once. Does it work?
int ledPin1 = 1;
int ledPin2 = 2;
int ledPin3 = 9;
int ledPin4 = 11;
int ledPin5 = 12;
int ledPin6 = 13;

void setup() {
//put your setup code here, to run once:
}
void loop() {
//put your main code here, to run repeatedly:
int QuestionNumberArray[] = {1, 2, 9, 11, 12, 13};//the array itself
const size_t n = sizeof(questionNumberArray) //the array used
sizeof(questionNumberArray[0]);//the base of the array

for (size_t i = 0; i < n - 1; i++) //the loop itself
{
size_t j = random(1, n-i);
int t = questionNumberArray[i]; //integer output for increase
questionNumberArray[i] = questionNumberArray[j];//the value definition
questionNumberArray[j] = t;
pinMode(questionNumberArray, INPUT);
if(digitalRead(questionNumberArray) == HIGH) {
then(digitalRead(1, 2, 9, 11, 12, 13) == HIGH)
break;
}
}

Also, how do I make it so that people have multiple tries to do it, or is it already like that?
Thank you

Hi err. I have reverted your last change that removed all contents of the question. Even when questions are put on hold, we leave its content as it was so it can be searched later.