Go Down

Topic: Best Arduino Board for Beginners? [HELP] (Read 6053 times) previous topic - next topic

Okay, sorry if i asked this question in the wrong section but I'm new here.
Basically, I've been developing software for quite a while now, and I would like to learn more about how it interacts with the hardware.
That's why I'm here.
I don't have any specific requirements, just a basic Arduino board, that would be best suited to a beginner, to use as a learning experience.
I've heard that the Duemilanove is meant to be good, but those posts were from a few years ago, so it may be outdated.

So what board do you think is best for me?

Regards, tokzikate.

johnwasser

The latest basic model is the Arduino UNO.  That would be an excellent starting point.  It will cost around $35 and the only other hardware you need to program it is a USB printer cable.

You can get "Arduino compatible" boards or even cheaper knock-off's that say "Arduino" but aren't.  Best to get an original.  If you are lucky a Radio Shack near you has them in stock.  If it doesn't say "Made in Italy" it's not a real Arduino.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

I have an older board that doesn't have a USB-in.

I was thinking I could splice a USB cable onto it. After all, the USB cable has 4 pins, the header has 4 pins. I should be able to make a connector that slides on and off those pins.

My question is just that once I've opened up the USB cable, which wire goes to which pin?

Thanks.

johnwasser


I have an older board that doesn't have a USB-in.

I was thinking I could splice a USB cable onto it. After all, the USB cable has 4 pins, the header has 4 pins. I should be able to make a connector that slides on and off those pins.

My question is just that once I've opened up the USB cable, which wire goes to which pin?


If it doesn't have the USB connector, does it have a place for the USB connector?  If not it probably doesn't have the USB-to-Serial chip.  In that case there is nowhere you can connect a bare USB cable to your non-USB Arduino to get it to work.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

MarkT

USB is a highly complex protocol, no chance of interfacing to it without a USB<->serial chip or cable.
[ I won't respond to messages, use the forum please ]

So much for newbie enthusiasm. Thanks for the info.

Hello

I was provided the below code which was written in VIM

it will not compile on arduino 1.0

help ?




// #include <limits.h>


#define SEVENS_TIMES 0.8
#define SAFESLEDGE_TIMES 4.545

#define INT_MAX 1

int peak = 0;
int last_peak = 0;
int cur_peak = 0;

float times_factor = 4.545;

#define POWER_OFF_PIN 4
#define SOUND_PIN     13
#define RESET_PIN  5
#define CHOOSE_PIN  6

// number of seconds to run the buzzer before turning off
#define BUZZER_OFF_AFTER 4


// used for the display
#define CLOCK_PIN  8
#define DATA_PIN   9
#define CLEAR_PIN  10

#define MILLISECONDS (1L)
#define SECONDS      (1000L * MILLISECONDS)
#define MINUTES      (60L   * SECONDS)

unsigned long lastaction; // used as a shutoff timer

struct gauge_instance {
  int sound_pin;
  int data_pin;
  int clock_pin;
  int clear_pin;
  int analog_pin;
  int peak;
  int last_peak;
  int cur_peak;
  unsigned long peakhit;
  unsigned long hitfinished;
  unsigned long buzzertoggle;
  int hit_new_peak;
  int reset_offset;
  int allow_hit;
  int buzzer_off;
  int buzzer_toggle;
  int pressure_offset;
  int buzzer_length_ms;
};

gauge_instance gauge_1 = {
  13, // Sound pin
  9, // data pin
  8, // clock pin
  10, // clear pin
  0, // analog pin
  0,0,0, //peaks
  0,0,0, // timers
  0, 0, 1, 1, 1, INT_MAX, // readings
  1000 //buzzer flicker in ms
};

gauge_instance gauge_2 = {
  12, //sound pin
  1, // data pin
  0, //clock pin
  2, // clear pin
  2, // analog pin
  0,0,0, // peaks
  0,0,0, // timers
  0, 0, 1, 1, 1, INT_MAX, // readings
  2000 //buzzer flicker in ms
};

gauge_instance gauges[] = {
  gauge_1, gauge_2 };


int digits[] = {
  0xfc, 0x60, 0xda, 0xf2, 0x66, 0xb6, 0xbe, 0xe0, 0xfe, 0xf6 };

int v_to_pressure(int v){
  /* multiply by 0.0049 to get actual voltage */
  float dv = v;
  float psi = 0.11054361738995178 * dv - 4.511984383263338;

  /* one atmosphere */
  psi -= 14.223;

  // multiply it up for the current physical setup
  psi *= 19;


  //float psi = 0.11054361738995178 * dv - 4.511984383263338;
  ///* one atmosphere */
  //psi -= 14.5;
  //psi *= (10.8 / 0.06 * 0.80);

  /* discard small values */
  if(psi < 50)
    //if(psi < 3)
    psi = 0;

  return psi;
}

void display_num(gauge_instance gauge, int number){
  // times it by five... since thats the ... times factor.
  //number = number * 5;
  // for sevens
  //number = number * 0.8;
  number = number * times_factor;
  int thousands = (number % 10000) / 1000;
  int hundreds = (number % 1000) / 100;
  int tens = (number % 100) / 10;
  int ones = (number % 10);

  digitalWrite(gauge.clear_pin, 1);
  shiftOut(gauge.data_pin, gauge.clock_pin, LSBFIRST, digits[ones]);
  shiftOut(gauge.data_pin, gauge.clock_pin, LSBFIRST, digits[tens]);
  shiftOut(gauge.data_pin, gauge.clock_pin, LSBFIRST, digits[hundreds]);
  shiftOut(gauge.data_pin, gauge.clock_pin, LSBFIRST, digits[thousands]);
  digitalWrite(gauge.clear_pin, 0);
  delay(4);
}

void reset_timer(unsigned long *timer){
  *timer = millis();
}


void setup() {
  pinMode(POWER_OFF_PIN, OUTPUT);
  digitalWrite(POWER_OFF_PIN, 0);

  pinMode(RESET_PIN, INPUT);
  digitalRead(RESET_PIN);


  for(int i =0; i < 2; i++) {
    pinMode(gauges.sound_pin, OUTPUT);
    digitalWrite(gauges.sound_pin, 0);

    pinMode(gauges.clock_pin, OUTPUT);
    pinMode(gauges.data_pin, OUTPUT);
    pinMode(gauges.clear_pin, OUTPUT);
  }

  pinMode(3, OUTPUT);

  // see if we're set up for safe sledge or sevens
  // choose will be high if we want sevens

  pinMode(CHOOSE_PIN, INPUT);

  delay(5);
  if(digitalRead(CHOOSE_PIN) == HIGH)
  {
    times_factor = SEVENS_TIMES;
  }
  else {
    times_factor = SAFESLEDGE_TIMES;
  }

  reset_timer(&lastaction);
}

int timesince(unsigned long timer, unsigned long duration){
  return (millis() - timer > duration);
}

void loop() {
  for(int i =0; i < 2; i++) {
    gauge_instance gi = gauges;

    if(digitalRead(RESET_PIN) == HIGH) {
      gi.cur_peak = gi.peak = gi.last_peak = 0;
      gi.pressure_offset = INT_MAX;  // where is INT_MAX declared??
      reset_timer(&lastaction);
    }


    int v = analogRead(gi.analog_pin);
    int val = v_to_pressure(v);
    if(val < gi.pressure_offset){
      gi.pressure_offset = val;
    }

    if(val < gi.pressure_offset + 5){
      /* blink between numbers */
      if(gi.cur_peak){
        gi.last_peak = gi.cur_peak;
        gi.cur_peak = 0;
      }
      if(millis() & 0x200){
        display_num(gi, gi.last_peak);
      }
      else{
        display_num(gi, gi.peak);
      }
    }
    else if(gi.allow_hit){
      gi.reset_offset = 1;
      reset_timer(&gi.hitfinished);
      if(val > gi.cur_peak){
        gi.cur_peak = val;
        if(gi.cur_peak > gi.peak){
          gi.peak = gi.cur_peak;
          /* play sound */
          digitalWrite(gi.sound_pin, 1);
          gi.buzzer_off = 0;
          reset_timer(&gi.peakhit);
          reset_timer(&gi.buzzertoggle);
        }
      }
      else if ( gi.cur_peak > (val + 50) ) {
        gi.allow_hit = 0;
      }

      display_num(gi, val);
      reset_timer(&lastaction);
    }
    else {
      reset_timer(&gi.hitfinished);
      display_num(gi, gi.cur_peak);
      //display_num(val);
    }

    if(timesince(gi.peakhit, BUZZER_OFF_AFTER * SECONDS)){
      digitalWrite(gi.sound_pin, 0);
      gi.buzzer_off = 1;
    }

    // run for 800 milliseconds
    if(timesince(gi.buzzertoggle, gi.buzzer_length_ms * MILLISECONDS)){
      reset_timer(&gi.buzzertoggle);
      if(gi.buzzer_off == 0) {
        gi.buzzer_toggle = ( gi.buzzer_toggle + 1) % 2;
        digitalWrite(gi.sound_pin, gi.buzzer_toggle);
      }
    }

    // we're going to resample the offset 5 seconds after every hit to prevent drift
    if(timesince(gi.hitfinished, 10 * SECONDS)){
      if(gi.reset_offset) {
        gi.reset_offset = 0;
        gi.pressure_offset = INT_MAX;
        gi.allow_hit = 1;
      }
    }
  }

  if(timesince(lastaction, 10 * SECONDS)){
    digitalWrite(POWER_OFF_PIN, 1);
  }
}






cowichan__dec25a:4: error: variable or field 'display_num' declared void
cowichan__dec25a:4: error: 'gauge_instance' was not declared in this scope
cowichan__dec25a:4: error: expected primary-expression before 'int'

MarkT

Please edit that post to put the code in code tags...
[ I won't respond to messages, use the forum please ]

johnwasser


cowichan__dec25a:4: error: variable or field 'display_num' declared void
cowichan__dec25a:4: error: 'gauge_instance' was not declared in this scope
cowichan__dec25a:4: error: expected primary-expression before 'int'


My best guess it that something has gone wrong in the translation from C to C++.  It seem to not like using the struct type gage_instance as a variable type.  Add the keyword 'struct' in these four places and it compiles:
Code: [Select]

struct gauge_instance gauge_1 = {
struct gauge_instance gauge_2 = {
struct gauge_instance gauges[] = {
void display_num(struct gauge_instance gauge, int number){

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Thanks for the replies, but I have one last question.
Is there any official online store, to get Arduino boards like the uno?
Or for a person like me,(Living in Australia) have to get one from eBay?

CrossRoads

Did you try the Store link at the top of the page?
Shows
Arduino Duemilanove w/ Atmega328 for 15 Euro.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Nevermind, I found a store! It turns out that they have a list of websites that sell the products, on a link from the home page...
Anyway, so I'm going to buy an Arduino Uno, I think that it is the right product for me!
Currently, the Arduino Uno is out of stock, but there are two other Uno boards on the same site.
The first one is called: "Arduino Uno SMD"
and the other is called: "Arduino Uno - R3"

Should I get one of them, or just wait for the standard Arduino Uno to be back in stock?

--------------------------------------------------------------------
Off-topic:            
I really appreciate the fast responses, most forums don't
have as many active users as this one, especially seeing that
you're helping me out, even though I haven't contributed to
these forums at all!


~tokzikate

CrossRoads

They are slight variations on the same thing.
Uno -> Uno SMD (came when DIPs were in short supply) -> Uno R2 -> Uno R3.

Uno R3 will be fine.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


Go Up