Show Posts
Pages: [1]
1  Using Arduino / Motors, Mechanics, and Power / Powering an Arduino with a laptop battery. on: September 06, 2012, 10:40:21 am
I'm going to be using an arduino as a computer of sorts on my bike. It'll be powering lights and a 16x2 lcd. I know this isn't a big power draw, but the reason I want to use a laptop battery is so that I can charge it once and not have to worry about it for months.
Here's the thing, I don't want to hook up a 14.4v 2.6 AHr battery to my arduino without some consultation. What would be a safe way to do this?
2  Using Arduino / Programming Questions / Re: How to have an Arduino wait until it receives data over serial? on: June 06, 2012, 02:14:33 am
The while loop should have nothing in the block. That way, you are telling it to sit still until you get something in the buffer, you then read it, parse it and loop.

Also, remove the Serial.flush(), it doesn't do what you think it does.
Haha! Perfect! Now to fill in all the functions! Thanks! smiley-lol
3  Using Arduino / Programming Questions / Re: How to have an Arduino wait until it receives data over serial? on: June 05, 2012, 10:59:48 pm
Use Serial.available() for the tester of the while loop
Code:
while(Serial.available() <= 0){}
Okay, I did that. I also made the variable "ch" a global variable so I would have to keep re-defining it. The loop works now, but it doesn't go back into the while loop once it gets out. It just keeps looping void loop. I tried adding a Serial.flush(), but it doesn't seem to have any effect.
Quote
#include <Servo.h>
Servo steering;
Servo throttle;
int pos = 0;
int val = 0;
char ch;
void setup(){
  Serial.begin(9600);
  throttle.write(90);
  steering.write(90);
  pinMode(A0, INPUT);
  pinMode(7, INPUT);
}
void loop(){
  Serial.println("Menu");
  Serial.println("--------------------");
  Serial.println("1. Motion Readout");
  Serial.println("2. Distance Readout");
  Serial.println("3. SD Directory Listing");
  Serial.println("4. Sound Test");
  Serial.println("5. Car Test");
  Serial.println("--------------------");
  Serial.println("Type the number and press enter");
while(Serial.available() <= 0){
    ch = Serial.read();
   }
   Serial.println(ch);
  switch(ch)
  {
    case '1':
    motion();
  }
   ch = 0;
   Serial.flush();
}
//menu over, lets get to work.
void motion(){
  Serial.println("Haha, it works!");
}

Do yourself a favor and change all of your serial prints to use PROGMEM.  Otherwise you are going to be debugging out of RAM issues in the near future.
I did that and it didn't do anything after the menu was printed. I changed it back.
4  Using Arduino / Programming Questions / [Resolved] How to have an Arduino wait until it receives data over serial? on: June 05, 2012, 09:45:07 pm
So I've wired up a little robot with a sound shield and some sensors. I'm trying to write a sketch that will let check the sensors.

What I'd like for it to do is print out a little menu over serial, wait until the user sends a selection, jump to the function that matches their selection, then (once the function is done) jump back and print the menu again. What it actually does is just loop the menu again and again, completely bypassing the while loop (I've tested this by putting a Serial.print in the loop to see if it gets in or not).
Here's what I've written, but I'm not a that good of a coder, so it doesn't work. Where am I going wrong?

Quote
#include <Servo.h>
Servo steering;
Servo throttle;
int pos = 0;
int val = 0;
void setup(){
  Serial.begin(9600);
  throttle.write(90);
  steering.write(90);
  pinMode(A0, INPUT);
  pinMode(7, INPUT);
  char ch = 0;
}
void loop(){
  Serial.println("Menu");
  Serial.println("--------------------");
  Serial.println("1. Motion Readout");
  Serial.println("2. Distance Readout");
  Serial.println("3. SD Directory Listing");
  Serial.println("4. Sound Test");
  Serial.println("5. Car Test");
  Serial.println("--------------------");
  Serial.println("Type the number and press enter");
  while(char ch = 0){
    ch = Serial.read();
   }
  char ch;
  switch(ch)
  {
    case '1':
    motion();
  }
   ch = 0;
}
//menu over, lets get to work.
void motion(){
  Serial.println("Haha, it works!");
}
I'm pretty sure a While loop is the right thing to do, but I'm probably implementing it wrong. Can anyone shed some light on this?
5  Using Arduino / Networking, Protocols, and Devices / Hyper Text Coffee Pot Control Protocol on: May 25, 2011, 02:29:28 am
So hooking up an arduino to a coffee maker is hardly a new idea, but what if it was network accessible and controllable using HTCPCP?

Has anyone implemented HTCPCP on the arduino?

Hyper Text Coffee Pot Control Protocol
6  Community / Exhibition / Gallery / Re: ¬| Project Sentry Gun |⌐ on: May 23, 2011, 05:04:33 am
I'm working on a similar project. Since you're already going to be using a computer to control the gun, have you considered using a more conventional image processing software like Roborealm? I've been looking into some all in one solutions and I stumbled across this, which might also be of interest to you.

Best of luck, fellow turret maker!
7  Using Arduino / Displays / Re: LMC-SS2A20 2x20 display on: May 23, 2011, 04:56:29 am
I will! And I was going through your site; you have a lot of really good stuff there! I can guarantee you I'll be using your password example and menu system in the final product of my turret. It's really slick!
8  Using Arduino / Displays / Re: LMC-SS2A20 2x20 display on: May 22, 2011, 06:02:27 pm
Yeah, you can sense all eight of them. They all trace to one ribbon cable that connects just perfectly to a breadboard!

I'm going to use this for a nerf turret I'm building. Gonna use the four buttons on the side to control the mode (activate, deactivate, test, Safety Timer start), hook up a PIR module to one of the other analog inputs (in digital input mode) and connect the sweeping servos and LEDs to the remaining digital pins.

I may switch to a Arduino Mega so I can use more LEDs and maybe an audio shield.
9  Using Arduino / Displays / Re: LMC-SS2A20 2x20 display on: May 22, 2011, 01:33:52 am
10  Using Arduino / Displays / Re: LMC-SS2A20 2x20 display on: May 21, 2011, 12:15:15 pm
Quote
Bad news is that it doesn't seem to match up at all with the table here: http://www.ladyada.net/learn/lcd/lcdshield.html
If you are talking about the table where it says "Shave & a haircut - 4 bits!" then I agree with you - it doesn't seem to make sense..  When I get a chance I will try and figure out where they went wrong.

The pin numbers are standard for all of the Hitachi compatible devices.  Use the tutorial that I mentioned in my first reply.  Your physical setup will look different since your pins are oriented in two parallel rows but the pin numbers will coincide.
Alright, I'll give it a shot.
Quote
Quote
Good news is I've got the display logic and back light working fine.
Did you get the single row of blocks and can you vary their intensity with the potentiometer?  If yes then you have already completed the hard part.  Just connect the other six wires to the Arduino, and make sure to ground pin 5 of the LCD module.  You can use any of the Arduino pins for any of the 6 connections to the LCD data and control pins, just make sure that the LiquidCrystal lcd() information matches your connections.

Don
Yes, I did get the black row (how I knew I got the logic powered), but the rest of the pins didn't make sense. Well, I'll use the pins as specified in the LCD Char tutorial you linked to. Actually, I like that tutorial as it was helpful to me when I bought a 16x2 lcd from adafruit.

Thanks again! I'll update once I get a chance today to try it out.
11  Using Arduino / Displays / Re: LMC-SS2A20 2x20 display on: May 21, 2011, 03:58:25 am
Okay, I can't get it to work but, through some trial and error, i've learned something. Pin 1 is ground, pin 2 is voltage in, and pin 3 is contrast control. Good news is I've got the display logic and back light working fine. Bad news is that it doesn't seem to match up at all with the table here: http://www.ladyada.net/learn/lcd/lcdshield.html

I found the datasheet for the nt3881, but I'm not skilled enough to make heads or tails of it.

If I scan the back of the board, would you guys be able to help me figure out the proper pins?
12  Using Arduino / Displays / LMC-SS2A20 2x20 display on: May 20, 2011, 09:33:29 pm
So I just had the opportunity to salvage parts from an old CD duplicator, including a LMC-SS2A20 2x20 display. Problem is, I'm still new to hardware hacking and I don't know if this is hitachi (read LiquidCrystal library) compatible.
Does anyone know anything about this display? The internet is pretty vague about it.
13  Topics / Device Hacking / Re: Brushed Motor Control through ESC on: February 11, 2011, 04:49:53 am
Hey 3Dawn, I'm also interfacing a Duemilanove with my RC car. I'm running a HPI E10, though, so it's more of a Driftduino. Haha. Glad to see you got it working. I used different code to test and work out the range of my ECS, though. I got it...somewhere, don't remember. It may even be one of the example sketches. lol Anyways, I'll post it up here if you're interested.

Code:
#include <Servo.h> 
Servo throttle;     
int pos = 0;
void setup()
{
  throttle.attach(8);
  Serial.begin(9600);
  Serial.println("Enter number and press 's' to send it to servo. Send 'stop' to stop moving.");
}
void loop()
{
  static int val = 0;
  if (Serial.available())
  {
    char ch = Serial.read();
    switch(ch)
    {
      case '0'...'9':
        val = val * 10 + ch - '0';
        break;
      case 's':
        throttle.write(val);
        Serial.print("Servos is set to: ");
        Serial.print(val, DEC);
        Serial.println(" degrees");
        val = 0;
        break;
    }
 }
 Servo refresh();
}

Also, here's my Driftduino sketch as well, just in case you ever feel like coming to the cooler side of RC racing. XD It's a bit rough (no sensors yet), but it's a work in progress.

Code:
#include <Servo.h>
Servo steering;  // create servo object called "steering" to control the steering servo
Servo throttle;
int pos = 0;    // variable to store the steering position
void setup()
{
  steering.attach(9);  // tells the arduino that the object "steering" should be associated with digital pin 9
  throttle.attach(8);  // and the throttle to pin 8
}
void loop()
{
  delay(4000);
  steering.write(90); //Center the steering
   //arm the Electronic Speed Controller (ESC)
  delay(1000); //gonna waggle the front wheels a bit to test the steering
  int max = 5;
  int i = 0;
  for(i = 0; i < max;i++){
    for(pos = 58; pos < 132; pos += 10)  // goes from 58 degrees (full right) to 132 degrees (full left)
    {                                  // in steps of 10 degree (fast)
      steering.write(pos);              // writes the position to the servo
      delay(15);                       // waits 30ms for the servo to reach the position
    }
    for(pos = 132; pos>=58; pos-=10)     // goes from 132 degrees to 58 degrees
    {                               
      steering.write(pos);              // writes the position to the servo
      delay(15);                       // waits 30ms for the servo to reach the position 
    }
  }
  delay(2000); //On your marks...
  steering.write(90); //get set...
  delay(100);
  throttle.write(130); //GO!
  delay(3000); //build up speed before the flick
  for(pos = 58; pos < 132; pos += 10)  // goes from 58 degrees (full right) to 132 degrees (full left)
  {                                   // in steps of 10 degree (fast)
    throttle.write(30);                  //BRAKE!
    steering.write(pos);              // writes the position to the servo
    delay(30);                       // waits 30ms for the servo to reach the position
  }
  for(pos = 132; pos>=58; pos-=10)     // goes from 132 degrees to 58 degrees
  {                                   
    throttle.write(170);    //Power on!
    steering.write(pos);              // writes the position to the servo
    delay(30);    // waits 30ms for the servo to reach the position
  }
  delay(1000);                   //holds the steering at full right lock for one second
  throttle.write(140);
  int maxd = 5;
  int d = 0;
  for(d = 0; d < maxd;d++){
  {
    steering.write(90);              //Sets the steering position to center
    delay(10);                       // waits 10ms for the servo to reach the position
  }
  delay(1000);                    //holds the steering at center for 1 second
  {                               
    steering.write(58);              // tell servo to go to position in variable 'pos'
    delay(30);                       // waits 15ms for the servo to reach the position
  }
  delay(500);
  }
  throttle.write(90);
  steering.write(60);
  delay(60000);                   //Now Sit. Good boy.
}
Pages: [1]