Show Posts
Pages: 1 ... 113 114 [115] 116
1711  Using Arduino / Programming Questions / Re: help making library on: September 25, 2011, 10:02:45 pm
And for clarificatio I don't need the lcd stuff in the library, that was just for me bugging
and srry for the poorly explained code, I usually don't neaten things up till it all works
1712  Using Arduino / Programming Questions / help making library on: September 25, 2011, 09:53:33 pm
Can anyone help me turn this code into a library?
I tried myself but i keep getting errors even tho ut looks the same as the tutorial,  every command and var gives me an err
if someone could make it and leave the files up thatd be greatly appreciated : )
im trying to make just one command called SIO(); that goes through the code snippet

Here's the working code just not in library for m lol

 #include "LiquidCrystal.h"

LiquidCrystal lcd(30, 31, 32, 22, 23, 24, 25);
int incoming = 0;
int command[4] = {0, 0, 0, 0};
int place = 0;
int pin;
int state;
int pinstatus;

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

}

void loop(){
  SIO();

}
     
 void SIO(){
         
  if(Serial.available() > 0){
    incoming = (Serial.read());
    if(incoming != 13){
    lcd.print(char(incoming));
    command[place] = incoming;
    place = place++;
    }
    }
    if(place >= 4){
      place = 0;
      pin = command[0] - 48;
      pin = pin * 10;
      pin += command[1] - 48;
      if(command[2] == 'O') state = 1;
      else;
      if(command[2] == 'I') state = 0;
      pinstatus = command[3] - 48;
      pinMode(pin, state);
      if(state == 1) digitalWrite(pin, pinstatus);
      if(state == 0) Serial.println(digitalRead(pin));
       }
      }
     
   
 
 
   


1713  Using Arduino / Project Guidance / Re: EEPROM better than SD card for audio ? on: September 21, 2011, 09:47:32 pm
Maybe it is a problem with your code and the way it reads the files, as if it is loooking for something and searches the whole thing
I've been using 4gb sd cards for a while now datalogging and reading back the information and I've had no hassles regardless of the size of the file
id check your code first for a bug before changing the storage medium, especially as an sd card is very cheap and very simple to use,
if your code is funny, complicating it with serial eeprom probably wont help
1714  Using Arduino / Project Guidance / Re: arduino mega 2560 ir library on: September 16, 2011, 04:37:21 pm
So if I substitute the uno pin for mega it will wori without code change because it is based on the timer mapping, correct?
1715  Using Arduino / Project Guidance / arduino mega 2560 ir library on: September 16, 2011, 02:37:57 pm
Im planning on a project utilizing the ir library but I was researching and it seems the mega2560 isn't directly compatible due to something with the timer 2 and different hardcoded pins
does a modded library exist that I can simply download, or do I need to modify the library file? Im good at arduino code sorta, so I probablly could but I don't know anything about the actual hardware or what to change
1716  Using Arduino / Project Guidance / Re: ideas needed on: September 15, 2011, 07:11:20 am
Build an arduino based rocket ship smiley-lol
1717  Using Arduino / Sensors / Re: ds18b20 filtering? on: September 15, 2011, 07:05:46 am
I have a 4.7 k resistor on it, and right now the distance is about 6 inches lol
maybe i got a faulty part?
1718  Using Arduino / Project Guidance / Re: arduino wont work properly without soft reset on: September 12, 2011, 10:44:21 pm
Thx for catching that typo I had in brightness, lucky for me it still did what I wanted by just running that anyway, which is why i probably didnt notice, I could probably remove the if(
and temp1 is just shorter lol, I could definetly use or reuse a more. Accurate name but with all the alterations I make sometimes its just easier to define a new variable
And what I do by setting it and checking it is my way of ensuring the device is working properly
if I set it to 9 and it returns something else I know something is fishy or not connected and draws the status to my startup screen

1719  Using Arduino / Sensors / Re: ds18b20 filtering? on: September 12, 2011, 10:29:40 pm
Yeah I was using it without parisitic mode : /
and I didn't mean that the 5v reg wasn't working but that the sensor was not working when the arduino is supplied with the 12v, the reg does put out 5 v pretty accuratly, but I think it doesn't regulate the usb in so I thought it may be related
1720  Using Arduino / Sensors / Re: Interface with car's RPM and Speed sensors on: September 09, 2011, 09:06:27 pm
A more expensive route, but 99% acuurate way eould be to interface the obd2 connection and request that info directly from the ecu,
You could get tons of other things too like temps, pressures, and other readings
It would depend tho if your car has obd2 and you felt like buying a shield for the interface
1721  Using Arduino / Sensors / Re: ATMega328 ADC Temperature compensation? on: September 09, 2011, 09:01:30 pm
Ive founf out in my setup that my measured vin is accurate to 1% -20mv
I used the same thing with a voltage divider,
If you need to keep the vref at 5, you can temporarily change it to 3.3, then measure your 5v out, then adjust back to vref
1722  Using Arduino / Sensors / ds18b20 filtering? on: September 09, 2011, 08:55:57 pm
I had two ds18b20's on my one wire bus, then one crapped out for sone reason, ni big deal, the next day tho my other was reading 0c constanly
Then i found out it worked fine if it was powered from usb, even tho 5v regulator wasnt good enough my 4.1 v usb worked?? And the onboard 5v line wouldnt work it when i powered from 12v vin
so i put a 10uf cap by the sensor and now its all good from eirher power
Can anyone explain why this happened?
1723  Using Arduino / Project Guidance / Re: arduino wont work properly without soft reset on: September 09, 2011, 08:12:39 pm
The display works fine, along with all the code for it,
the touchscreen is separate and is the 4 wire resistive type
I trid the delay before and after the one wire code thinking that since that's what's causing it I should isolate it it, it seems to only be the actuall communication, becajse if no sensors are on the line its fine

Edit
Here is involved code, the ehole code is 30kb
 

p = ts.getPoint(); // touch reading code that fails the first powerup, part of main loop   
 
   if (p.z > MINPRESSURE && p.z < MAXPRESSURE) {  //touch reading refinement     
     p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0); //     x reading                   
     p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0);//        y reading               
     
if(brightness = 1){
       
       screentimer = time;
       brightness = 0;
       digitalWrite(LCD_BRIGHTNESS, brightness);
     }
 }


sensors.begin(); // part in setup, and the root of all evil, but only the first time assuming a device is on the line
sensors.setResolution(insideThermometer, TEMPERATURE_PRECISION);
sensors.setResolution(outsideThermometer, TEMPERATURE_PRECISION);


temp1 = sensors.getResolution(insideThermometer);
temp2 = sensors.getResolution(outsideThermometer);

if(temp1 !=9){    // these dont cause it, i added afterwards
  tft.println("TEMP1 BAD");
}
if(temp1 == 9){
  tft.println("TEMP1 GOOD");
  temp1 = 1;
}
if(temp2 !=9){
  tft.println("TEMP2 BAD");
}
if(temp2 == 9){
  tft.println("TEMP2 GOOD");
  temp2 = 1;
}
oneWire.reset();  // tried with and without this thought maybe it was hanging



// sensor read code in main loop

if(time - sensorreadtimer > sensreaddelay){
     sensorreadtimer = time;
     temperature1 = 0;
     temperature2 = 0;
     sensors.requestTemperatures();
     if(temp1 == 1){
     temperature1 = sensors.getTempC(insideThermometer);
     temperature1 = DallasTemperature::toFahrenheit(temperature1);
     }
     if(temp2 == 1){
     temperature2 = sensors.getTempC(outsideThermometer);
     temperature2 = DallasTemperature::toFahrenheit(temperature2);
     }

     
     analogRead(A13);
     rawvoltage = vref * analogRead(A13); //voltage sensor
     rawvoltage = rawvoltage / 1024;  // to mv
     rawvoltage = rawvoltage * 6.5767; // times the voltage divider constant
     batteryvoltage = rawvoltage; // to actual voltage sensed

     analogRead(A12);
     rawcurrent = vref * analogRead(A12); // conv to mv, not finished
     rawcurrent = rawcurrent / 1024;
     rawcurrent = rawcurrent - 2.5; ratiometric
     rawcurrent = abs(rawcurrent);
     batterycurrent = rawcurrent;
   }
1724  Using Arduino / Project Guidance / arduino wont work properly without soft reset on: September 09, 2011, 07:41:19 pm
I recently added ds18b20's to my project and aver aince then my touchscreen code has been being skipped until i press reset, after that it works 100%
Ive been debugging it by turning on and off the pin 13 led at various time and noting the timing of my main loop during normal operation,
I've found that the timing is different during the initial loop after power on, and that my code that maps the xy of the touchscreen ceases to run, basically skipping it
I press reset and it runs fine : /
Anyone have any solutions for me? The only I can think of is to try to self reset only once after power on, probably with this code
 void(* resetFunc) (void) = 0; //declare reset function @ address 0
 ResetFunc(); //call reset

Problem is id like to not use eeprom to sorta save its already been reset, its for my car which, may turn on and off rapidly during ignition,  and I can't add like something that turns off the resetting to the missed code because its only run if its touched

1725  Using Arduino / Project Guidance / Re: arduino in car on: September 03, 2011, 10:33:12 pm
Im using female to male jumper wires I got off ebay, they make it real easy to move things around
especially since this project requires 28 different connections to my arduino mega
And so far ive had no problems with them

And that seems like an interested power supply, ive didnt know they made them that small
Pages: 1 ... 113 114 [115] 116