Show Posts
Pages: 1 [2] 3 4 5
16  Using Arduino / Sensors / Digital potentiometer or similar??? on: March 19, 2013, 09:42:32 pm
I use my arduino mega 1280 to run my bus simulator's dashboard, easy enough for the warning lights, and the tachograph is fairly easy needing just a pulsed signal (i use the tone output command)

But the 3 gauges are another story,

These are standard automotive air core style gauges (fuel, water temp and oil pressure) they have 3 terminals, power, earth and sender,

Power is easy... 24 volts DC, earth... well earth or 0 volts from the psu,

The sender terminal expects to be connected to a variable resistance to earth, 10 - 180 ohms.

I've tried before with other gauges using a PWM signal from the arduino (via a transistor, and without powering the gauges with 5 volts) but i could never get the full scale movement, and each gauge acted differently despite being the same model type.

So i was wondering about a way to feed these gauges a real-ish variable resistance,
i've heard of digital potentiometers, but was wondering if there was anything else i could try,
The gauges do not need to be that accurate, as long as they sort of track the on screen virtual gauges, so having steps between resistances is ok if they are small enough,

i had thought about driving a potentiometer with a servo, but do not want the noise servo's make if it can be helped.
17  Using Arduino / Motors, Mechanics, and Power / Re: HK-5320 servo dosent like the standard servo paramiters on: March 01, 2013, 07:19:48 pm
oh they don't get hot when not moving, and they are only pulling a quadrant gear to move the needle on a gauge, so a very small load,

it's just when they are running on the sweep pattern, they get hot,

i know servo's should all run on around 20ms, but apparently these run much better on 16ms,

i imagine that they would be absolutely fine, as they won't be sweeping across the dial all the time when in use, one will be slowly moved to a certain position, then will vary slowly to represent air tank pressure,
the other will move fast to positions varying on brake chamber pressure indicated, then go back to zero position and stay there most of the time,

Just they are fitted inside an automotive gauge, which requires the bezel prizing off to gain access, so i'd really rather not have to open it up again in a few weeks time to replace a burn out servo if i can avoid it by changing a few parameters of the library now.

if it matters, these are 1.7g servo's, about the smallest rotary servo's you can get, i did try those featherlight linear servo's, but they were naff, lots of backlash due to the way the screw thread is mounted to move the horn along the linear pot,

Just found out these servo's are actually rated for 2.8 to 4.2 volts, so i've been over volting them a little rather than under volting them,

They come with a micro JST connector fitted, so are designed to plug into those feather light RX boards for indoor planes or small helicopters, which usually run on a single cell LiPo, and hence they 'could' have a different pulse requirment to normal servo's?

Also they have a 140 degree motion, but move 90 degrees on the 1 to 2ms pulses, needing 0.8 to 2.2ms to get max rotation.
18  Using Arduino / Motors, Mechanics, and Power / Re: HK-5320 servo dosent like the standard servo paramiters on: March 01, 2013, 06:33:11 pm
I'm running the servos at exactly 4.8 volts from my bench psu, they consume very very low currents as expected as they are really tiny servo's,
they run a little faster at 6 volts, but i don't want to burn them out as they get hot enough at 4.8 volts,

And yup i have the grounds connected between the psu and arduino,

There are a few references on the web about these particular servo's not liking the standard servo library settings, and most mention 16ms is the sweet spot for these, but i'm not sure how to implement that, not even 100% sure if it is milliseconds or microseconds, as the positioning part is done in microseconds.
19  Using Arduino / Motors, Mechanics, and Power / HK-5320 servo dosent like the standard servo paramiters on: March 01, 2013, 05:07:13 pm
I am converting a couple of dual needle brake pressure gauges from air to servo operation,

So i needed the smallest servo's i could get, and the HK-5320's are perfect, absolutely tiny things they are,

As i work out the linkage and positions inside the gauge, i have my uno running the servo sweep sketch,

However the HK-5320's are running hot, buzzing a bit and not giving me full sweep.

I've seen someone on youtube mention he found out the HK-5320's run best on a 16ms pulse or something, and standard arduino servo code is 22ms.

Can someone tell me what i need to do to make my servo's happy??
The servo's will eventually be running on my mega, and moving according to data from a simulator as a varying value from 0 to 1024.
20  Using Arduino / Programming Questions / Help combining lcd and keypad scripts on: February 01, 2013, 03:56:34 pm
I'm using an arduino uno as the heart of a replica of a bus ticket machine, basically a 32 buton keypad and an lcd,

I have the lcd part working fine, however i am just using standard button inputs to trigger each message displayed on the lcd (i.e. a pin to ground via a switch)

I need to use the keypad matrix sketch for my 32 buttons, i have that sketch working also, but sending the keypad assignments to the serial monitor,

Can someone advise me what i need to change to merge the 2 scripts, so that it reads the keypad on a 9x4 matrix, and certian keys are assigned to display certain messages on the lcd when pressed.

My lcd sketch :
Code:
#include <LiquidCrystal.h>

int buttonPin0= 0;    //sets pins buttons are connected to
int buttonPin1= 1;
int buttonPin2= 2;
int buttonPin3= 3;
int buttonPin4= 4;
int buttonPin5= 5;
int buttonPin6= 6;
int buttonPin7= 7;

LiquidCrystal lcd(A5, A4, A3, A2, A1, A0); //sets pins lcd is connected to, running in 4 bit mode, RW pin tied to gnd, and i'm using the analog pins as i need the digital pins for the buttons
byte selectionMade = false; //code to only allow print button to work after certain other buttons have been pressed
void setup()

{
  byte selectionMade = false; //sets to no selection made yet, so print button will not respond

  pinMode(buttonPin0, INPUT);
  pinMode(buttonPin1, INPUT);  //assigns button pins as inputs
  pinMode(buttonPin2, INPUT);
  pinMode(buttonPin3, INPUT);
  pinMode(buttonPin4, INPUT);
  pinMode(buttonPin5, INPUT);
  pinMode(buttonPin6, INPUT);
  pinMode(buttonPin7, INPUT);

  digitalWrite(buttonPin0, HIGH);
  digitalWrite(buttonPin1, HIGH);  //sets internal pulldown resistors
  digitalWrite(buttonPin2, HIGH);
  digitalWrite(buttonPin3, HIGH);
  digitalWrite(buttonPin4, HIGH);
  digitalWrite(buttonPin5, HIGH);
  digitalWrite(buttonPin6, HIGH);
  digitalWrite(buttonPin7, HIGH);

  lcd.begin(20, 1);  //set up lcd
  lcd.setCursor(20,0);  //put cursor to end of lcd
  lcd.print("Gazz's D92 dashboard for Omsi, Der Omnibussimulator");  //prints text to lcd
  for (int positionCounter = 0; positionCounter < 51; positionCounter++)  { //maths bit for scrolling
    lcd.scrollDisplayLeft();   //scrolls text
    delay(250);
  } //sets speed of scrolling
  lcd.clear(); //clears lcd ready for main use
}

void loop(){
  int buttonState0 = digitalRead(buttonPin0);
  int buttonState1 = digitalRead(buttonPin1); 
  int buttonState2 = digitalRead(buttonPin2);
  int buttonState3 = digitalRead(buttonPin3);
  int buttonState4 = digitalRead(buttonPin4);
  int buttonState5 = digitalRead(buttonPin5);
  int buttonState6 = digitalRead(buttonPin6);
  int buttonState7 = digitalRead(buttonPin7);

  if (buttonState0 == LOW) {
    selectionMade = true;     
    lcd.setCursor(0,0);
    lcd.print("Fahrschein Nor  2.70");  //German for single ticket, stays on the lcd until another buttons is pressed
  }

  else if(buttonState1 == LOW){
    selectionMade = true;
    lcd.setCursor(0,0);
    lcd.print("Kurzstr Norm    1.70");  //German for short trip ticket, stays on lcd untill another button is presed
  } 

  else if (buttonState2 == LOW){
    selectionMade = true;
    lcd.setCursor(0,0);
    lcd.print("Tageskarte Nor  9.00");  //German for day ticket, stays on display untill another button is pressed
  }   

  else if (buttonState3 == LOW){
    selectionMade = true;
    lcd.setCursor(0,0);
    lcd.print("Fahrschein Erm  1.70");  //German for kids ticket

  } 

  else if (buttonState4 == LOW){
    selectionMade = true;
    lcd.setCursor(0,0);
    lcd.print("Kurzstr Erm     1.20");  //German for kids short trip ticket
  }
  else if (buttonState5 == LOW){
    selectionMade = true;
    lcd.setCursor(0,0);
    ;
   lcd.print("Kurf");
   lcd.print(char(245));
   lcd.print("rstendamm  1.00");  //Ku'damm ticket, Berlin shopping street only
  }
  else if(buttonState6 == LOW){
    selectionMade = false;
    lcd.clear();  //cancel button, clears display

  }
  else if   
    (buttonState7 == LOW && selectionMade == true){
    lcd.setCursor(0,0);  //clears display
    lcd.print("   >>Belegdruck<<   ");  //German for 'printing ticket' only displayed after ticket selection made
    delay(350);
    lcd.noDisplay();
    delay(250);
    lcd.display();
    delay(350);
    lcd.noDisplay();
    delay(250);
    lcd.display();
    delay(550);
    lcd.clear();
    selectionMade = false; //resets the selection state to needing ticket preselection again
  }


}

And the keypad sketch:

Code:
#include <Keypad.h>

const byte ROWS = 4; //4 rows
const byte COLS = 9; //9 columns

char hexaKeys[ROWS][COLS] = {
  {'0','1','2','3','4','5','6','7','8'},
  {'9','A','B','C','D','E','F','G','H'},
  {'I','J','K','L','M','N','O','P','Q'},
  {'R','S','T','U','V','W','X','Y','Z'}
};
byte rowPins[ROWS] = {3, 2, 1, 0}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {12, 11, 10, 9, 8, 7, 6, 5, 4}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad cusomKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup(){
  Serial.begin(9600);
}
 
void loop(){
  char customKey = cusomKeypad.getKey();
 
  if (customKey != NO_KEY){
    Serial.println(customKey);
  }
}

I think i will need to keep the button state part of the script, but change it to point to the keypad assignments for the buttons??
21  Using Arduino / Displays / Re: LCD pulsing text on: January 27, 2013, 05:22:17 pm
i'm an idiot,

it was switch bounce,
i'd found parts of cod on various sites, put them together, not realising that by setting the input pins to LOW wasn't doing anything, hence with my buttons going high to be read, the inputs were floating, and i was effectively sending loads of button press commands,

changed the script on the advise of people at my local hackspace....

Code:
#include <LiquidCrystal.h>

int buttonPin1= 6;    //sets pins buttons are connected to
int buttonPin2= 7;
int buttonPin3= 8;
int buttonPin4= 9;
int buttonPin5= 13;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //sets pins lcd is connected to, running in 4 bit mode, RW pin tied to gnd

void setup()
{
  pinMode(buttonPin1, INPUT);  //assigns button pins as inputs
  pinMode(buttonPin2, INPUT);
  pinMode(buttonPin3, INPUT);
  pinMode(buttonPin4, INPUT);
  pinMode(buttonPin5, INPUT);

  digitalWrite(buttonPin1, HIGH);  //sets internal pulldown resistors
  digitalWrite(buttonPin2, HIGH);
  digitalWrite(buttonPin3, HIGH);
  digitalWrite(buttonPin4, HIGH);
  digitalWrite(buttonPin5, HIGH);

  lcd.begin(20, 1);   //lcd size
  lcd.print("Der Omnibussimulator"); //welcome text
  delay(2000);  //displays for 2 secs
  lcd.clear();  //clears display
}


void loop(){
  int buttonState1 = digitalRead(buttonPin1); 
  int buttonState2 = digitalRead(buttonPin2);
  int buttonState3 = digitalRead(buttonPin3);
  int buttonState4 = digitalRead(buttonPin4);
  int buttonState5 = digitalRead(buttonPin5);


  if (buttonState1== LOW){
    lcd.setCursor(0,0);
    lcd.print("Fahrschein Nor  2.70");  //German for single ticket, stays on the lcd untill another buttons is pressed
  }
  else if(buttonState2== LOW){
    lcd.setCursor(0,0);
    lcd.print("Kurzstrecke     1.70");  //German for short trip ticekt, stays on lcd untill another button is presed
  } 
  else if (buttonState3== LOW){
    lcd.setCursor(0,0);
    lcd.print("Tageskarte      9.00");  //German for day ticket, stays on display untill another button is pressed
  } 
  else if(buttonState4== LOW){  //button pressed
    lcd.setCursor(0,0);  //clears display
    lcd.print("   >>Belegdruck<<   ");  //German for 'printing ticket'
    delay(350);
    lcd.noDisplay();
    delay(250);
    lcd.display();
    delay(350);
    lcd.noDisplay();
    delay(250);
    lcd.display();
    delay(550);
    lcd.clear();
  }
  else if(buttonState5== LOW){
    lcd.clear();
  }
}
And it all works, instant response from the buttons, no delays other than those i put in to flash the 'printing ticket' text,

Now to work out how to integrate the 9x4 button matrix into this script, having about 10 or 11 of the matrix'd buttons displaying text on the lcd, the other buttons are to be ignored by tis part of the script.
22  Using Arduino / Displays / Re: HD44780 LCD with pre-defined segments on: January 27, 2013, 02:37:17 pm
i picked one of those bags of displays from maplins yesterday, and have the exact same lcd,

it is apparantly out of a multimeter type thing, to be used on 3 phase equipment i believe,

if you put the part number into google, it'll throw up a few sites, a lot of them are italian, but they all seem to say the same thing, ignore the bottom half row of symbols, and just use it as a 1 line display,
23  Using Arduino / Displays / Re: LCD pulsing text on: January 27, 2013, 10:53:22 am
Nope, even with the delays removed, it still takes it's time,

i've changed a few things, got rid of all delays except the one that keeps the 'Belegdruck' text on screen for a short while, then clears the screen, makes no difference if i remove that delay too,

Code:
#include <LiquidCrystal.h>

int buttonPin1= 6;
int buttonPin2= 7;
int buttonPin3= 8;
int buttonPin4= 9;

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

void setup()
{
  pinMode(buttonPin1, INPUT);
  pinMode(buttonPin2, INPUT);
  pinMode(buttonPin3, INPUT);
  pinMode(buttonPin4, INPUT);

  digitalWrite(buttonPin1, LOW);
  digitalWrite(buttonPin2, LOW);
  digitalWrite(buttonPin3, LOW);
  digitalWrite(buttonPin4, LOW);
}


void loop(){
  int buttonState1 = digitalRead(buttonPin1);
  int buttonState2 = digitalRead(buttonPin2);
  int buttonState3 = digitalRead(buttonPin3);
  int buttonState4 = digitalRead(buttonPin4);

  if(buttonState1== HIGH){
    lcd.setCursor(0,0);
    lcd.print("   >>Belegdruck<<   ");
    delay (100);
    lcd.clear();
  }
   
  else if (buttonState2==HIGH){
    lcd.setCursor(0,0);
    lcd.print("Fahrschein Nor  2.70");
  }
  else if(buttonState3== HIGH){
    lcd.setCursor(0,0);
    lcd.print("Kurzstrecke     1.70");
  } 
  else if(buttonState4== HIGH){
    lcd.setCursor(0,0);
    lcd.print("Tageskarte      9.00");
  } 
}


The above code works just like before, i removed all the 'int prevButtonState' bits, as i figured they were not needed, the script i got this info from originally had a message on the screen whenever no buttons were pressed, changing to show which were pressed, then back to no button is pressed displayed.

But basically, if i press button 4, it displays it's text, if i then press button 3, it changes immediately to button 3's text, same if i press button 2 after button 3 or 4, and pressing button 1 does the 'Belegdruck' thing, and clears the display,

However, if i press say button 2, then press button 4, it waits about 4 seconds before changing the text to that of button 4, i.e. i can go down the button numbers instiantly, but going up them gives the delays,

Also, even with the button 1 delay before clearing the lcd set for 100 millis, it takes 4 seconds to clear the display.

Something is causing the delay... i can't believe it's the time it takes the loop part of the script to run??
24  Using Arduino / Programming Questions / Re: Need Help With Arduino :-| on: January 27, 2013, 08:11:53 am
Cool,

On mine i have just ran all the led's directly off the arduino, i.e. each led, i connect the anode through a suitable resistor to run it at 15Ma on 5 volts, and then to the arduino's output pin i want to control that led,

All the cathodes from the led's are tied together and go back to one of the GND pins on the arduino (the one next to pin 13 on the uno is connected to the ones by the 3.3 and 5v pins on the other side of the board btw)

Now, i may be stressing my arduino by doing this, i believe the max current that should be drawn from any 1 pin is 20Ma.... and i have just realised i am running about 10 white led's off one pin for the instrument backlights.. oops,

I am not sure if the current limit applies when the arduino pins are sinking the current... someone else can answer that as i am just not sure,

But for now, i'd not bother with an external power supply on your set up, as it's only 6 leds, and the arduino is more than capable of running that load,

i only need 12 volts in my set up as i have automotive gauges that run on 12 volts, i also have 24 volts for a few illuminated buttons that just do not look right with led's in them, but as i mentioned, when mixing voltages, you really need to keep them seperate and away from the arduino,
25  Using Arduino / Displays / Re: LCD pulsing text on: January 26, 2013, 09:59:06 pm
i've tried another way, and it's working a lot better,

However, it has a big delay, about 2 seconds before it registers a button press and displays the text,
it's probably a silly mistake, but i am not sure what it is,
and not sure i can do this kind of sketch with a button matrix,

Code:
#include <LiquidCrystal.h>

int buttonPin1= 6;
int buttonPin2= 7;
int buttonPin3= 8;
int buttonPin4= 9;

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

int prevButtonState1;
int prevButtonState2;
int prevButtonState3;
int prevButtonState4;

void setup()
{
  pinMode(buttonPin1, INPUT);
  pinMode(buttonPin2, INPUT);
  pinMode(buttonPin3, INPUT);
  pinMode(buttonPin4, INPUT);
 
  digitalWrite(buttonPin1, LOW);
  digitalWrite(buttonPin2, LOW);
  digitalWrite(buttonPin3, LOW);
  digitalWrite(buttonPin4, LOW);
 
  lcd.begin(20, 1);
  lcd.print("Omsi Almex a90");
  delay(2000);
  lcd.clear();
}


void loop(){
  int buttonState1 = digitalRead(buttonPin1);
  int buttonState2 = digitalRead(buttonPin2);
  int buttonState3 = digitalRead(buttonPin3);
  int buttonState4 = digitalRead(buttonPin4);
 
  if (buttonState1 == LOW && prevButtonState1== HIGH){
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Fahrschein Nor  2.70");
    prevButtonState1 = buttonState1;
  }
  else if(buttonState2 == LOW && prevButtonState2== HIGH){
    lcd.clear();
    lcd.print("Fahrschein Erm  1.70");
    prevButtonState2 = buttonState2;
  } 
  else if(buttonState3 == LOW && prevButtonState3== HIGH){
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Tageskarte      9.00");
    prevButtonState3 = buttonState3;
  }
  else if(buttonState4 == LOW && prevButtonState4== HIGH){
    lcd.clear();
    lcd.print("    >>Drucken<<     ");
    delay(2000);
    lcd.clear();
    prevButtonState4 = buttonState4;
  }
    else{
    prevButtonState1 = buttonState1;
    prevButtonState2 = buttonState2;
    prevButtonState3 = buttonState3;
    prevButtonState4 = buttonState4;
 }
  }
26  Using Arduino / Displays / Re: LCD pulsing text on: January 26, 2013, 08:16:11 pm
Thanks mate,

I thought it might have been clearing and re-writing to the display all the time,

i found that if i press all 3 buttons at once, the display becomes solid and is nice and readable, so i guess i am locking something up doing that... i'll only ever press one button at a time in my finished design anyway.

Unfortunately this is all new to me, i just found some code on the net, and it kind of does what i want... but i need to modify it for my own use now,

Not sure i need to check the message is already displayed before writing to the display? as if it is, it will just flash once when it is updated???

the goal is definately to only write to the display when something changes, either a 'ticket' selection button, the canel button 'clear display' or print ticket : display 'printing' then clear display,

So, i assume i need to scan all inputs for changes, detect an input, check if the button pressed has a lcd function assigned to it, if so, either write that message on the lcd, clear the display or display the 'printing' message, wait 2 seconds, then clear the display,

I have slightly modified the keypad sketch to work with my button matrix :
Code:
#include <Keypad.h>

const byte ROWS = 4; //4 rows
const byte COLS = 9; //9 columns
//define the symbols on the buttons of the keypads, Ideally i want the real keys, i.e. 'Fahrschein Nor', 'Kurzstrecke', 'Ausgabe' etc,
//but the hexakeys thing i think only reads/displays the last letter.
char hexaKeys[ROWS][COLS] = {
  {'0','1','2','3','4','5','6','7','8'},
  {'9','A','B','C','D','E','F','G','H'},
  {'I','J','K','L','M','N','O','P','Q'},
  {'R','S','T','U','V','W','X','Y','Z'}
};
byte rowPins[ROWS] = {3, 2, 1, 0}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {12, 11, 10, 9, 8, 7, 6, 5, 4}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad cusomKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup(){
  Serial.begin(9600);
}
 
void loop(){
  char customKey = cusomKeypad.getKey();
 
  if (customKey != NO_KEY){
    Serial.println(customKey);
  }
}

i wonder if i could alter the bit where it sends the charecters to serial, to send them to the lcd, and assign text to be displayd instead of just the button assignment number/letters,
27  Using Arduino / Displays / LCD pulsing text on: January 26, 2013, 06:52:37 pm
I'm trying to put together bits of code to eventually end up with a 9x4 matrix of button inputs, send each individual button pressed as a HID usb gamepad, whilst certian buttons display text on a lcd.

I have got the lcd working, running it in 4 bit mode, it's a 20 x 1 character module... which is from the bus ticket machine i am interfacing to a computer simulator,

So now  i am looking having button presses display different text on the lcd, eventually it will need to scan the matrix'd buttons, and display text for about 10 different buttons being pressed,

Text to display will be ticket type, to stay on the display untill either the cancel button is pressed, or the print ticket button is pressed, when the display is to change to show 'printing' for 2 seconds, then blank the display.

This is my script so far... a combination of the standard lcd library, and a bit of script i found from someone who wanted 3 buttons to display text,


Code:
// include the library code:
#include <LiquidCrystal.h>
#include <Wire.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int switchPin = 10;              // switch is connected to pin 10
int switchPin1 = 9;              // switch is connected to pin 9
int switchPin2 = 8;              // switch is connected to pin 8
int prevState;                     // variable for reading the pin status
int currState;                // variable to hold the last button state

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(20, 1);
 
  pinMode(switchPin, INPUT);     // Set the switch pin as input
  pinMode(switchPin1, INPUT);    // Set the switch pin as input
  pinMode(switchPin2, INPUT);    // Set the switch pin as input
}

 void loop(){
  currState = digitalRead(switchPin);
 
  if(currState !=prevState){
 
  if(currState == LOW){
  lcd.println("   ");
  lcd.clear();
 
  }
   
   
  else {
   
  prevState = currState;
  currState = digitalRead(switchPin);
  if(currState !=prevState)
  lcd.print(0, 0);
  lcd.print("Fahrschein Erm  1.70");
 
  }
  }
  prevState = currState;

 currState = digitalRead(switchPin1);
 
  if(currState !=prevState){
  if(currState == LOW){
  lcd.println("   ");
  lcd.clear();
  }
  else {
   
  prevState = currState;
  currState = digitalRead(switchPin1);
  if(currState !=prevState)
  lcd.print(0, 0);
  lcd.print("TagesKarte      9.00");
 
  }
  }
  prevState = currState;
 
 
  currState = digitalRead(switchPin2);
 
  if(currState !=prevState){
  if(currState == LOW){
  lcd.println("   ");
  lcd.clear();
  }
  else {
   
  prevState = currState;
  currState = digitalRead(switchPin2);
  if(currState !=prevState)
  lcd.print(0, 0);
  lcd.print("Fahrschein Nor  2.70");
 
  }
  }
  prevState = currState;
  }


It works, however the text is pulsing when it is shown, not flashing, but pulsing from bottom to top, as if it's being refreshed at too slow a rate,
or it might be because of the code that is keeping a look out for button presses?

I also see no way to alter how long the text stays displayed for, ATM it displays for about 4 or 5 seconds, then blanks, and there is a delay if you press another button before it changes the text.

Is there a better way to do what i am trying, and will this even be compatable with matrix buttons when i try and add that part of the code?
28  Using Arduino / Programming Questions / Re: Need Help With Arduino :-| on: January 26, 2013, 06:28:18 pm
I put the codes needed on my site, linked from my youtube page...

www.kampenwagen.co.uk

Hopefully that should get your led's turning on and off with the game's dashboard light (remember i use a mega, so have many more outputs than a uno)

I havent tried using my arduino for inputs, i used a leo bodnar usb input board for that, i'd recomend the
http://www.leobodnar.com/shop/index.php?main_page=index&cPath=86
It's a usb button box input board, just connect any buttons to it, assign them in the gam, and roberts your wifes sisters hubby,

I have recently blown my bodnar input board, mis-wired a voith gear selector, and shoved 24 volts for the lights up an input pin, so i now have a U-HID from ultimarc, twice the price of the leo bodnar board (or 3 times if you go for the solder the pins on your self version) but it is more than an input board (can do a few outputs, but mainly it can easily be set up for pulse on switch down, pulse on switch up, so no need to faff about modifying every bus's script to handle latching switches in omsi.


Hope some of this helps,
Gazz
29  Using Arduino / Project Guidance / Re: Leonardo, combining scripts. on: January 12, 2013, 05:26:34 pm
at least 20 inputs, 8 PWM outputs, and around 15 on/off outputs,
and possibly later 5 analogue inputs.

If i could get my mega to work with inputs it'd be ideal, but i'm not sure i can do that, as it needs to show up on the computer as a HID gamepad/joystick.
30  Using Arduino / Project Guidance / Re: Leonardo, combining scripts. on: January 10, 2013, 06:56:18 pm
Quote
Oh, sure I have a dozen of them sitting around. Not!
That was a hint for you to post a link.

D'oh, here ya go,
http://www.leobodnar.com/products/BU0836/


Code:
void Read_Blinker(const unsigned int value)
{
  if (value == 1)
  {
        digitalWrite(24,HIGH);
  }
  else
  {
        digitalWrite(24,LOW);
  }
}
You have a really funny definition of Read. I suppose the function to get input is called Write_something().

I'll admit i know very little about programming, it's just so hard to get my head around it,
A friend helped me write the script as well as completely writing the DLL that starts the comunications from the game to the arduino,

All i know is it works.... the bit of code above is to flash the indicator led in the dashboard on and off in time with the one in the game,

Unfortunately my friend can no longer help me with this project, so i am stuck, i don't even have the source code for the DLL, so i can't add more functions... even if i knew how to.
Pages: 1 [2] 3 4 5