Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Yakattak
Dec 17, 2009

I am Grumpypuss
>:3

nightchild12 posted:

That is totally possible. Easiest way is probably to use the Metro library as a timer to see if ~200 ms has passed between keypresses. I haven't used it myself so this may not be right, but here's something along the lines of what you want:

code:
Metro keypressTimer = Metro(2000); // set up timer with 2000ms period
char keyArray[10] = {'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'};
int keyArrayIndex = 0;

void loop(){

  if( keypressTimer.check() == 1 && keyArray[0] != '\0' ) { // if timer expired and keyArray has contents
    Serial.println(keyArray); // print keyArray
    keyArray = {'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'}; // clear keyArray
    keyArrayIndex = 0; // reset keyArrayIndex
  }

  char key = keypad.getKey(); // read in key press

  if (key != NO_KEY){ // if we got a value for the key press
    keyArray[keyArrayIndex] = key; // put key press into keyArray
    if(keyArrayIndex < 9) {keyArrayIndex++}; // increment index if it won't overflow
    keypressTimer.reset(); // reset timer
  }
}
The above makes several assumptions. I haven't included most of your keypad code. The length of keyArray should be set to the longest string of characters you expect. The tenth input value will be modified if more keys are pressed before the timer expires but after you've filled the array. I am assuming that \0 is an acceptable way to write a null character. You might be better off using a string object rather than an array for this. I haven't tested this to see if it will run or even checked it very thoroughly for correctness. You can also roll your own timer using millis() instead of using Metro.

But that's a basic way you can do it. Run a timer which resets each time a key is pressed, and only output when the timer expires or reaches a certain value.

You are a god among men, thank you. Can't wait to try this out!

Adbot
ADBOT LOVES YOU

huhu
Feb 24, 2006

TVarmy posted:

The Teensy and Digisparks are cool if you're interested in either a smaller/cheaper footprint, which is great for certain projects.

Get some mosfets and an led light strip roll for big led projects.

If you're interested in controlling an appliance, say a rice cooker for sous vide cooking, a relay kit or solid state relay is nice. Be careful of mains power, though. And never plug the Arduino into a bare mechanical relay, as it takes too much power, and if it does switch, when it turns off, it can send a jolt that fries can fry the board.

A raspberry pi is kind of a peripheral, in the way that a tall wags a dog, but the two boards work really well together, and it really simplifies stuff like hosting a server that works with physical input/output, logging data, tweeting, processing images from a camera, etc. Just send the Arduino commands from python or c over serial.

Awesome thanks for the suggestions. Definitely going to purchase a few of these. Would love to do stuff like controlling an appliance but I probably won't have electricity. Will purchase a solar pack before I go though. Going to look into some practical things for my home. So far thought of doing a battery powered night light with a switch. If anyone has any tips for making practical things since I'll be living pretty basic I'm all ears.

Acid Reflux posted:

huhu, I've got a discrete component collection that rivals lots of small stores. I'd be *more* than happy to put together a care package for you with a variety of capacitors, diodes, and a wider range of resistors for you if you'd like. Nothing worse than being stuck in the middle of nowhere, unable to complete a project due to lack of materials. :)
Awesome! I'll keep this in mind. Thanks.

Edit: Started making a game. :smug: Basically a game where you balance the light within the row of lights. I made a little introduction and started the basic mechanics of it. Might be my first "permanent" project.


View My Video

huhu fucked around with this message at 04:17 on Mar 12, 2013

huhu
Feb 24, 2006
Having an issue with the project I posted about in the last post. The issue is that I have it set so that there is an analogRead of the pins connected to the left and right directions of the joy stick. When the value of 0 is recorded on the left or right joystick, it moves the light in that direction. There is background noise produced that sometimes leads the light to move without the joystick moving it in that direction. How can I go about filtering this noise out?

Bad Munki
Nov 4, 2008

We're all mad here.


Is this just a problem with when the joystick is untouched and should be dead in the center, or are you actually experiencing issues when moving it around off-center?

For the former, the simplest solution would be to simply have a dead-zone, i.e. consider (x, y) = (0, 0) if abs(x, y) < (10, 10), for instance. Or if you want a circular dead zone instead of a rectangular one, use a threshold on the distance vector from (0, 0) to (x, y) instead.

If the latter, probably the easiest solution would be to have a "mobile" dead zone as above, but use the difference between the current reading and the previous one. That is, consider (x, y) = (oldx, oldy) if abs((x, y) - (oldx, oldy)) < (10, 10). Obviously, you preserve (oldx, oldy) until you detect sufficiently large movement, as opposed to updating it each time whether you discarded the new reading or not. If you updated it each time, then very slow movements of the joystick would get ignored.

Alternately, as above except keep a running average of the last 10 (or 100, or 1000, or whatever) reads, and use the same mobile dead-zone idea.

Bad Munki fucked around with this message at 02:03 on Mar 25, 2013

huhu
Feb 24, 2006
I don't think that's quite what I'm looking for or maybe I'm misunderstanding you.

Here is a sample output of
code:
  int right = analogRead(0);
  int left = analogRead(1);
  Serial.println(right);
  Serial.println(left);

output posted:

548
556
503
516
454
483
426
457
397
429
378
400
322
346
239
279
143
195
53
117
0
88
34
107
That one zero in there shouldn't be there. I'd preferably like the values to be at their max until the joystick is pushed to the left or right at which point a value of zero would be registered. I think the issue I'm running into is similar to this: http://youtu.be/_LCCGFSMOr4?t=10m38s but I'm not sure.

Another issue. I want a loop to start that when pressed in a direction left, will cause the LED to shift once every 300ms to the left, until the direction right is pressed causing the LED to shift to the right every 300ms. Where should I place this loop? Here is my current code using a while loop for each direction.

code:
int count=0;
int currentOn=7;                               //currentOn variable is the current LED position.
void setup()
{
  Serial.begin(9600);
  digitalWrite(currentOn,HIGH);
}

void loop() {
 leftright();
}

// ****************Break up for Move Left/Right *********************************
int leftright(){
  int right = analogRead(0);           //Read value from joystick right 
  int left = analogRead(1);            //and left. 
  Serial.println(right);
  Serial.println(left);
  delay(500);                          //Large delay for testing purposes.
  if (right == 0)
  {
    digitalWrite(currentOn,LOW);       // The current LED is turned off
    currentOn-=1;                      //the position is decreased by one
    digitalWrite(currentOn,HIGH);      //and the new current LED is set to high. 
    while(currentOn <= 15)                  
    {
      delay(300);
      digitalWrite(currentOn,LOW);
      currentOn+=1;
      digitalWrite(currentOn,HIGH);
    }
  }

  if (left == 0)                       //Same code as previous if statement except in the opposite direction. 
  {
    digitalWrite(currentOn,LOW);        
    currentOn+=1;
    digitalWrite(currentOn,HIGH);
    while(currentOn >= 0)
    { 
      delay(300);
      digitalWrite(currentOn,LOW);
      currentOn-=1;
      digitalWrite(currentOn,HIGH);
    }
  }
}}


:woop: Added a break in there and it works. Just need to remove the noise issue and I'll be done.

huhu fucked around with this message at 02:50 on Mar 25, 2013

Bad Munki
Nov 4, 2008

We're all mad here.


If I'm reading your output right, it's printing x,y,x,y,x,y,x,y,x,y etc, so every other value is for one axis. In which case, that 0 was preceded by 53 and followed by 34, which doesn't seem TOO far off. I mean, you were bring the joystick "down" along that axis. What is the full range of each axis? That is, does it go from 0 at the middle up/down to +/-MAX, or is it 0 on one edge and MAX on the other?

huhu
Feb 24, 2006

Bad Munki posted:

If I'm reading your output right, it's printing x,y,x,y,x,y,x,y,x,y etc, so every other value is for one axis. In which case, that 0 was preceded by 53 and followed by 34, which doesn't seem TOO far off. I mean, you were bring the joystick "down" along that axis. What is the full range of each axis? That is, does it go from 0 at the middle up/down to +/-MAX, or is it 0 on one edge and MAX on the other?

The outputs are x,y. I didn't move the joystick at all for those readings.

Bad Munki
Nov 4, 2008

We're all mad here.


Ohhhhhhhhhh, hahaha. I thought you were slowly dragging the joystick across the field. So what's the actual range if you do move it from min to max?

The reason I ask is because that'll help us figure out a "good" size for the dampening zone.

Also, I'm not clear on why the 0 shouldn't be there. What's so offensive about that one value? If you didn't move the joystick at all, they should all be roughly in the same range, so there's more going on here than just one errant value: your joystick is drifting from roughly 500 to 0 by sitting still (which also makes the min/max values important.)

To be clear: you're not seeing bounce or similar as described in the video you linked. You're seeing some massive drift that is likely brought on by any number of other issues. Dealing with that drift is (apparently) what you actually need to do. I say massive because the range of values on analogRead() is [0-1023] and since you claimed you didn't move the joystick at all, a drift of 500 is half your entire range. That is, without touching it, your joystick drifted the equivalent of moving it from the center, all the way to hard against one edge.

With that in mind, I'd want to see a schematic of your circuit to make sure you're not doing something wrong that is causing the voltage coming from the joystick to slowly decrease.

Bad Munki fucked around with this message at 04:05 on Mar 25, 2013

evensevenone
May 12, 2001
Glass is a solid.
Is it normal for left and right to be on separate axes? Shouldn't they just be one axis?

Can you post a diagram of how you have it connected?

huhu
Feb 24, 2006

evensevenone posted:

Is it normal for left and right to be on separate axes? Shouldn't they just be one axis?

Can you post a diagram of how you have it connected?

I disconnected the entire part of the circuit that goes to the LEDs by removing the ground. I then placed A0, A1, and ground into the joy stick directly from the Arduino. Also, here is a graph of what the background noise looks like. :science:

Edit: Here is the joystick. http://www.chproducts.com/1000-Series-v13-d-746.html

Only registered members can see post attachments!

huhu fucked around with this message at 05:37 on Mar 25, 2013

evensevenone
May 12, 2001
Glass is a solid.
What I'm saying is that usually a joystick has two potentiometers, one for each axis. A pot has 3 leads, and one lead is ground, one lead is +5V, and one lead is signal. And the signal will go from 0 to 5 as you go from one side to another.

But you said you connect left to A1 and right to A0. That doesn't make any sense. There should be an X axis that is left/right and a y-axis that is up/down.



edit: or is it a digital stick?

edit2: Ok, it looks like it's digital. You shouldn't need the analog pins at all. But lets just stick with them for now. I'm pretty use it's using SPDT switches, which also have three leads. You should connect it the same way. You should also put a 1k or 10k resistor in between the +5V and the switch (just in case of a short, which is super-unlikely).

Now it should read 0V or 5V and never anything in between.

evensevenone fucked around with this message at 05:56 on Mar 25, 2013

huhu
Feb 24, 2006
The wire connection to the joystick looks like:(horrible rough sketch)

[1][2][3][4][5]

Where A0 and A1 were hooked up to [1] and [2], [3] is the ground, and [4] and [5] are for the other axis. I'm not using [4] an [5].

Bad Munki
Nov 4, 2008

We're all mad here.


evensevenone posted:

What I'm saying is that usually a joystick has two potentiometers, one for each axis. A pot has 3 leads, and one lead is ground, one lead is +5V, and one lead is signal. And the signal will go from 0 to 5 as you go from one side to another.

But you said you connect left to A1 and right to A0. That doesn't make any sense. There should be an X axis that is left/right and a y-axis that is up/down.

Yeah, that had me puzzled as well. There's almost no way one axis has two outputs since they are, by definition, mutually exclusive. Unless, as was suggested, it's digital.

Got a make/model for the stick?


e: Edits bring more info.

If it is digital, yeah, you don't need to be doing analog anything. Also, in that case, you will need to debounce it, but that's not the problem you were seeing thus far, because you were only reading once every half a second or so in your test code up there.

Bad Munki fucked around with this message at 05:59 on Mar 25, 2013

evensevenone
May 12, 2001
Glass is a solid.

huhu posted:

The wire connection to the joystick looks like:(horrible rough sketch)

[1][2][3][4][5]

Where A0 and A1 were hooked up to [1] and [2], [3] is the ground, and [4] and [5] are for the other axis. I'm not using [4] an [5].

Ok, that doesn't make sense either. You need to be giving it some voltage somewhere. The pictures of the joysticks on the link had a total of 12 terminals. You can share the ground pin and the voltage supply, but you don't have a voltage supply at all.


edit: can you post a picture of the joystick showing what leads are connected where, and a photo of plug?

evensevenone fucked around with this message at 06:07 on Mar 25, 2013

Aurium
Oct 10, 2010

huhu posted:

The wire connection to the joystick looks like:(horrible rough sketch)

[1][2][3][4][5]

Where A0 and A1 were hooked up to [1] and [2], [3] is the ground, and [4] and [5] are for the other axis. I'm not using [4] an [5].

Leave the connections as is, and turn the internal pullups on the arduino on. If you have any other components connected to the joystick, remove them. Ground on the joystick directly to the ground, and the connection pins directly to the arduino. I'm assuming there are no pullup or pull down resistors in the joysitck. You can check this with a multimeter. The connection between the switch pin and the ground should either be an open circuit or a short circuit.

You'll need to use the pins as digital pins, but that's ok, analog pin 0 is digital pin A0. Analog pin 1 is digital pin A1, and so forth.

So put this in your setup function.
code:
pinMode(A0, INPUT);
digitalWrite(A0, HIGH);
To read the state of the joystick, just do digitalRead(A0);

When nothing is pushed both of the digitalRead()s will be HIGH, when one is pushed that one will go LOW. This assumes that the switches are wired to be normally open. It is possible that they are wired to be normally closed, if this is the case, this will be inverted.

After this happens you may wind up with switch bounce like you saw in the video. It depends a bit on the quality of the switches. Also, in that video, you may have noticed the little resistor on the switch. That resistor is acting like a pulldown or pullup resistor (I didn't watch enough of the video to know if he says either way). The arduino actually has some of these resistors built into it, when we write high to an input pin, (DigitalWrite(A0, HIGH)) we turn on the resistor that is built into that pin.

Aurium fucked around with this message at 06:21 on Mar 25, 2013

Captain Capacitor
Jan 21, 2008

The code you say?
I saw this on Lifehacker earlier and thought I would share. This guy put together some common components and what's required to use them.

On his website he's got some great pinout diagrams of all of the common Arduino boards. His site is a bit odd, but all of the diagrams are in PDF format in the reference section.

HATE TROLL TIM
Dec 14, 2006
I've got some older code here that's calling prog_uchar to store an array of data in PROGMEM, however it seems that prog_uchar is deprecated and the Arduino IDE won't allow me to compile it.

Here's the data:
code:
prog_uchar startscreenMV[1024] PROGMEM={
<MSB Vertical DEC Array>
};
I'm calling that ike this:


void setup() {
mydisp.begin();
mydisp.clearScreen();
mydisp.print("Uploading new start screen... (1024 bytes)");
mydisp.uploadStartScreen(1024,startscreenMV);
delay(1000);
mydisp.clearScreen();
mydisp.print("Done!");


Obviously that's giving me an error since uchar is deprecated. So I tried const unsigned char instead. That compiles and uploads, but it just spits garbage out to the display, so obviously it's not right.

What would be the correct replacement for prog_uchar?

Edit: Here's the library and sample code if anyone wants to have a look... http://www.digole.com/images/file/Tech_Data/DigoleSerial.zip

HATE TROLL TIM fucked around with this message at 05:13 on Mar 27, 2013

nightchild12
Jan 8, 2005
hi i'm sexy

HATE TROLL TIM posted:

I've got some older code here that's calling prog_uchar to store an array of data in PROGMEM, however it seems that prog_uchar is deprecated and the Arduino IDE won't allow me to compile it.

I'm calling that like this:

prog_uchar startscreenMV[1024] PROGMEM={ <snip> };


void setup() {
mydisp.begin();
mydisp.clearScreen();
mydisp.print("Uploading new start screen... (1024 bytes)");
mydisp.uploadStartScreen(1024,startscreenMV);
delay(1000);
mydisp.clearScreen();
mydisp.print("Done!");


Obviously that's giving me an error since uchar is deprecated. So I tried const unsigned char instead. That compiles and uploads, but it just spits garbage out to the display, so obviously it's not right.

What would be the correct replacement for prog_uchar?

Edit: Here's the library and sample code if anyone wants to have a look... http://www.digole.com/images/file/Tech_Data/DigoleSerial.zip

The correct data type to use is const unsigned char. The uploadStartScreen() function wants an unsigned char pointer.

The relevant function from that library:

code:
void DigoleSerialDisp::uploadStartScreen(int lon, const unsigned char *data) {
     int j;
     uint8_t c;
    Print::print("SSS");
    write((uint8_t) (lon % 256));
    write((uint8_t) (lon / 256));
    for (j = 0; j < lon;j++) {
        if((j%32)==0)
         delay(50);
         delay(_Comdelay);
        c=pgm_read_byte_near(data+j);
        write(c);
    }
}
Are you just running the example with no other modifications? Do you have the Wire library installed and in the right place for the Digole stuff to reach it ("../Wire/Wire.h")? Are you using UART, I2C, or SPI? Is it hooked up right for using whatever method (visible in comments at the top of uploadStartScreenandFonts.ino)?

I think there is a problem other than the data type you are using. Can you get it to display anything meaningful at all? Like, clear the screen and put a few characters without messing around with the start screen or fonts or anything? Strip it down to something like the below and make sure that works, then add pieces back one by one:

code:
#define _Digole_Serial_I2C_  //To tell compiler compile the special communication only, 
//other available is: _Digole_Serial_I2C_ and _Digole_Serial_SPI_
#include <DigoleSerial.h>
#include <Wire.h>
DigoleSerialDisp mydisp(&Wire,'\x27');  //I2C:Arduino UNO: SDA (data line) is on analog input pin 4, and SCL (clock line) is on analog input pin 5 on UNO and Duemilanove
#define LCDCol 16
#define LCDRow 2
#define LCDW 240
#include <sampledata.h>
void setup() {
  mydisp.begin();
  mydisp.clearScreen();
  mydisp.print("TEST OUTPUT");
  delay(500);
}
edit: Also FYI, your code block with the big long data block for the start screen data is breaking the poo poo out of my tables.

edit2: I did a little more looking around. prog_uchar is deprecated? I can't find an official source for that. Have you tried including the <avr/pgmspace.h> library? I noticed that the PROGMEM reference page says you need to "#include <avr/pgmspace.h>" in order to use PROGMEM, and that it isn't included anywhere in the DigoleSerial library or example.

edit3: OK, prog_uchar is deprecated according to the avr-libc website. Looks like the correct way to do this is: const unsigned char startscreenMV[1024] PROGMEM. Here's the old typedef: typedef unsigned char PROGMEM prog_uchar.

nightchild12 fucked around with this message at 00:32 on Mar 27, 2013

huhu
Feb 24, 2006
:woop::woop::woop:

Just finished my first actual interesting project. I remember way back when I was proud to make a light blink. Code is a little hosed up still but I'm going to let it be. The introduction light sequence for the game has been commented out since I took the easy method of solving one of my issues with the code. Eventually I'll revisit this project, add different difficulty settings and mount it permanently as well as fix the coding issue.

Goal of the game is to keep the light within the bounds of the light strip. Score is how many times you go back and forth with the joystick. It speeds up every click by a slight amount. Once the game ends the score is printed through the serial port.
View My Video

Also, I've started working on the control system I was talking about earlier. Got it all wired up to work. Now I just need to convert everything into the case I 3D printed and solder everything together. :suicide:. I feel like all my posts are a combination of :woop: and :suicide:





PS. My 3D print job isn't that lovely, I just had to force the Arduino through since I didn't make the holes big enough. Don't worry though, I fried that Arduino awhile ago.

Edit: Time for more (uneducated) questions. Since I'm done coding, I'd like to remove my Arduino Uno from the setup for my game and run it some other way. I was looking at the Mini but it's $10 plus the $15 for the adapter so I can write code from USB to the Mini. I'm guessing this isn't the solution but can I put the code on the Atmega328 chip and then hook up everything to that with the chip plugged directly into a breadboard? I'm assuming this isn't the answer so I turn to SA for help. How should I solve this?

Edit2: Does anyone know of running the Arduino coding atmosphere on Android? I've tried searching Google and keep ending up with ways to run your programs on Android. I'm currently looking into a laptop/tablet for Peace Corps and I've pretty much decided on a Tablet that runs Android and would like to be able to write code on it and send that to the Arduino but I can't find anything about doing this.

huhu fucked around with this message at 02:48 on Mar 27, 2013

Bad Munki
Nov 4, 2008

We're all mad here.


huhu posted:

Edit: Time for more (uneducated) questions. Since I'm done coding, I'd like to remove my Arduino Uno from the setup for my game and run it some other way. I was looking at the Mini but it's $10 plus the $15 for the adapter so I can write code from USB to the Mini. I'm guessing this isn't the solution but can I put the code on the Atmega328 chip and then hook up everything to that with the chip plugged directly into a breadboard? I'm assuming this isn't the answer so I turn to SA for help. How should I solve this?

You can absolutely do that, it's the norm: once you're done prototyping, ditch the prototyping board. You can get a bare atmega and flash the bootloader yourself and then dump your code on it, or you can get one from, say, sparkfun, with the bootloader already in place, and you just plug it into the socket on your arduino and dump your program on it. Once you've done that, you're free to pull the atmega out of the socket on the arduino and install it somewhere else. Google around for barebones arduino or something like that to find out the bare minimum of what you need to use it as you expect. It's pretty drat simple.

For that reason, in fact, it's nice to keep a few spare atmegas around and just one actual arduino. Then you can avoid sacrificing an arduino for every project.

HATE TROLL TIM
Dec 14, 2006
You can even order the ATmega328's on Amazon! Just ordered a bunch from Virtuabotix: http://www.amazon.com/ATMEGA328P-PU-with-Arduino-Bootloader-Uno/dp/B007SH0D0A/

They're literally cheap enough I bought 10 just to have on hand. Here's a 17 pack of 28 pin DIP sockets for $5 with Prime shipping: http://www.amazon.com/Gino-Sockets-Adaptor-Solder-Socket/dp/B0079SLYGU/

Grab yourself some breakable headers and you can make your own Arduino for less than $5 each: http://www.amazon.com/Single-11MM-Male-Header-Strip/dp/B008G8YTUA/

HATE TROLL TIM
Dec 14, 2006

nightchild12 posted:

The correct data type to use is const unsigned char. The uploadStartScreen() function wants an unsigned char pointer.

The relevant function from that library:

code:
void DigoleSerialDisp::uploadStartScreen(int lon, const unsigned char *data) {
     int j;
     uint8_t c;
    Print::print("SSS");
    write((uint8_t) (lon % 256));
    write((uint8_t) (lon / 256));
    for (j = 0; j < lon;j++) {
        if((j%32)==0)
         delay(50);
         delay(_Comdelay);
        c=pgm_read_byte_near(data+j);
        write(c);
    }
}
Are you just running the example with no other modifications? Do you have the Wire library installed and in the right place for the Digole stuff to reach it ("../Wire/Wire.h")? Are you using UART, I2C, or SPI? Is it hooked up right for using whatever method (visible in comments at the top of uploadStartScreenandFonts.ino)?

I think there is a problem other than the data type you are using. Can you get it to display anything meaningful at all? Like, clear the screen and put a few characters without messing around with the start screen or fonts or anything? Strip it down to something like the below and make sure that works, then add pieces back one by one:

code:
#define _Digole_Serial_I2C_  //To tell compiler compile the special communication only, 
//other available is: _Digole_Serial_I2C_ and _Digole_Serial_SPI_
#include <DigoleSerial.h>
#include <Wire.h>
DigoleSerialDisp mydisp(&Wire,'\x27');  //I2C:Arduino UNO: SDA (data line) is on analog input pin 4, and SCL (clock line) is on analog input pin 5 on UNO and Duemilanove
#define LCDCol 16
#define LCDRow 2
#define LCDW 240
#include <sampledata.h>
void setup() {
  mydisp.begin();
  mydisp.clearScreen();
  mydisp.print("TEST OUTPUT");
  delay(500);
}
edit: Also FYI, your code block with the big long data block for the start screen data is breaking the poo poo out of my tables.

edit2: I did a little more looking around. prog_uchar is deprecated? I can't find an official source for that. Have you tried including the <avr/pgmspace.h> library? I noticed that the PROGMEM reference page says you need to "#include <avr/pgmspace.h>" in order to use PROGMEM, and that it isn't included anywhere in the DigoleSerial library or example.

edit3: OK, prog_uchar is deprecated according to the avr-libc website. Looks like the correct way to do this is: const unsigned char startscreenMV[1024] PROGMEM. Here's the old typedef: typedef unsigned char PROGMEM prog_uchar.

I'm using I2C. I can get the Text Serial example to compile, upload and display just fine on the OLED module. Someone in #arduino in Freenode was helping me this morning and said the examples were compiling fine for them. I downloaded the current IDE for my Mac and was able to compile it as well, so this tells me something is up with the version of avr-libc running on my Raspberry Pi. I'm running avr-libc 1.8.0 and gcc-avr 4.7.0, so I'm not sure if that's in line with the "official" IDE or not.

I actually did get it working this afternoon after a few emails back and forth with the Chinese dude from Digole. Turns out they had some errors in their library. He fixed it and uploaded a new version. That, along with the knowledge that images need to be converted to an MSB vertical format, not LSB horizontal. I was able to compile it with prog_uchar on my Mac, then copy the .hex over to the RPi and upload it with my custom version of avrdude (modified to allow programming via a Gertboard over SPI).



I'm going to play with the code now to see if I can get it converted to the const unsigned char type so I can actually use it from the RPi. :)

MiNDRiVE
Nov 8, 2012
I'm currently working with a Leonardo and I was having trouble with SPI between the arduino and a 25LC1024 from Microchip. So I hooked it up to a really crappy 20mhz analog scope and noticed a lot of glitches on the sweep. Because of these glitches it made triggering on my signal next to impossible. Ultimately the fix for the glitches was to disable interrupts on the Arduino. Does anybody know how I could find out which interrupt or interrupts were the cause of the oscilloscope glitches?

Captain Capacitor
Jan 21, 2008

The code you say?

huhu posted:

:woop::woop::woop:

Just finished my first actual interesting project. I remember way back when I was proud to make a light blink. Code is a little hosed up still but I'm going to let it be. The introduction light sequence for the game has been commented out since I took the easy method of solving one of my issues with the code. Eventually I'll revisit this project, add different difficulty settings and mount it permanently as well as fix the coding issue.

Goal of the game is to keep the light within the bounds of the light strip. Score is how many times you go back and forth with the joystick. It speeds up every click by a slight amount. Once the game ends the score is printed through the serial port.
View My Video

Also, I've started working on the control system I was talking about earlier. Got it all wired up to work. Now I just need to convert everything into the case I 3D printed and solder everything together. :suicide:. I feel like all my posts are a combination of :woop: and :suicide:





PS. My 3D print job isn't that lovely, I just had to force the Arduino through since I didn't make the holes big enough. Don't worry though, I fried that Arduino awhile ago.

Edit: Time for more (uneducated) questions. Since I'm done coding, I'd like to remove my Arduino Uno from the setup for my game and run it some other way. I was looking at the Mini but it's $10 plus the $15 for the adapter so I can write code from USB to the Mini. I'm guessing this isn't the solution but can I put the code on the Atmega328 chip and then hook up everything to that with the chip plugged directly into a breadboard? I'm assuming this isn't the answer so I turn to SA for help. How should I solve this?

Edit2: Does anyone know of running the Arduino coding atmosphere on Android? I've tried searching Google and keep ending up with ways to run your programs on Android. I'm currently looking into a laptop/tablet for Peace Corps and I've pretty much decided on a Tablet that runs Android and would like to be able to write code on it and send that to the Arduino but I can't find anything about doing this.

I can vouch that the Micro is pretty drat awesome, but it is the Mega32u4 instead of the 328

MiNDRiVE
Nov 8, 2012

huhu posted:

:woop::woop::woop:

Just finished my first actual interesting project. I remember way back when I was proud to make a light blink. Code is a little hosed up still but I'm going to let it be. The introduction light sequence for the game has been commented out since I took the easy method of solving one of my issues with the code. Eventually I'll revisit this project, add different difficulty settings and mount it permanently as well as fix the coding issue.

Goal of the game is to keep the light within the bounds of the light strip. Score is how many times you go back and forth with the joystick. It speeds up every click by a slight amount. Once the game ends the score is printed through the serial port.
View My Video

Also, I've started working on the control system I was talking about earlier. Got it all wired up to work. Now I just need to convert everything into the case I 3D printed and solder everything together. :suicide:. I feel like all my posts are a combination of :woop: and :suicide:





PS. My 3D print job isn't that lovely, I just had to force the Arduino through since I didn't make the holes big enough. Don't worry though, I fried that Arduino awhile ago.

Edit: Time for more (uneducated) questions. Since I'm done coding, I'd like to remove my Arduino Uno from the setup for my game and run it some other way. I was looking at the Mini but it's $10 plus the $15 for the adapter so I can write code from USB to the Mini. I'm guessing this isn't the solution but can I put the code on the Atmega328 chip and then hook up everything to that with the chip plugged directly into a breadboard? I'm assuming this isn't the answer so I turn to SA for help. How should I solve this?

Edit2: Does anyone know of running the Arduino coding atmosphere on Android? I've tried searching Google and keep ending up with ways to run your programs on Android. I'm currently looking into a laptop/tablet for Peace Corps and I've pretty much decided on a Tablet that runs Android and would like to be able to write code on it and send that to the Arduino but I can't find anything about doing this.

You can remove the Arduino from the project completely and use another cheaper AVR chip for the final product. I would recommend an attiny85 for this project. It has 8 pins and 8k of flash which should be more than enough. You could use your Arduino board as the programmer for the attiny but you will have to design the ICSP circuit and do some soldering to make it permanent. If you go this route group the DIP version of the chip and you snag a 8 pin DIP socket from just about anywhere. The only other components you would need would be an external crystal and some decoupling capacitors. Hell you could even get by without the external crystal if you wanted. There are Arduino cores out there for the attiny so getting the code to work on that chip would be trivial. Hope this points you in the right direction.

http://avrprogrammers.com/attiny85bd.php
http://hlt.media.mit.edu/?p=1695

Delta-Wye
Sep 29, 2005

MiNDRiVE posted:

You can remove the Arduino from the project completely and use another cheaper AVR chip for the final product. I would recommend an attiny85 for this project. It has 8 pins and 8k of flash which should be more than enough. You could use your Arduino board as the programmer for the attiny but you will have to design the ICSP circuit and do some soldering to make it permanent. If you go this route group the DIP version of the chip and you snag a 8 pin DIP socket from just about anywhere. The only other components you would need would be an external crystal and some decoupling capacitors. Hell you could even get by without the external crystal if you wanted. There are Arduino cores out there for the attiny so getting the code to work on that chip would be trivial. Hope this points you in the right direction.

http://avrprogrammers.com/attiny85bd.php
http://hlt.media.mit.edu/?p=1695

I think switching to an ATTiny will require a heavy rewrite of the code because he is relying on the Arduino framework for a lot of stuff.

TVarmy
Sep 11, 2011

like food and water, my posting has no intrinsic value

Delta-Wye posted:

I think switching to an ATTiny will require a heavy rewrite of the code because he is relying on the Arduino framework for a lot of stuff.

Digisparks and a few forks of Arduino for the ATiny exist, so it wouldn't be ASM or c minus the Arduino code necessarily, but the savings are minimal, and it opens the door for a lot of headaches, and you'll have to check what features are supported.

It's about $1-2 vs $3-5 per chip, if I recall digikey's prices right.

TVarmy fucked around with this message at 22:06 on Mar 27, 2013

huhu
Feb 24, 2006
Just found out my university is sponsoring a 24 hour hackathon including Arduino as one of the choices. Anyone have any suggestions for goal to try and code for in 24 hours? Will be brainstorming myself over the next few days what I'd like to do but would love to hear some suggestions. I feel like I still haven't fully realized the capabilities of this board.

overeager overeater
Oct 16, 2011

"The cosmonauts were transfixed with wonderment as the sun set - over the Earth - there lucklessly, untethered Comrade Todd on fire."



What sort of peripherals/sensors do you have available?

One project that comes to mind is writing an emulator for an early microcomputer, like the SSEM or the Kenbak-1. The instruction set shouldn't take too long to implement, and the only components you need are switches and LEDs, plus a few multiplexers or shift registers depending on how many of those you add.

HATE TROLL TIM
Dec 14, 2006
My ATmega328 chips came in today. I already had a bag full of 16mHz crystals and all the caps and resistors, so I followed a guide I found on Virtuabotix and made a Bareduino. Works great and cost me about the same as a double cheeseburger!

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

HATE TROLL TIM posted:

My ATmega328 chips came in today. I already had a bag full of 16mHz crystals and all the caps and resistors, so I followed a guide I found on Virtuabotix and made a Bareduino. Works great and cost me about the same as a double cheeseburger!



Why is there a socket on that breadboard, can't you just plug the chip into the breadboard directly?

HATE TROLL TIM
Dec 14, 2006

peepsalot posted:

Why is there a socket on that breadboard, can't you just plug the chip into the breadboard directly?

I always socket them to protect the pins. I'd rather break the pin of a $0.05 socket than a $5 chip. Occasionally I'll transfer the chip to another, bigger breadboard or stick it in the socket (yes, I stick the socket in a socket) on the Gertboard. Basically it'll stay in the socket until I remove it to place it in a permanent home.

MiNDRiVE
Nov 8, 2012

HATE TROLL TIM posted:

My ATmega328 chips came in today. I already had a bag full of 16mHz crystals and all the caps and resistors, so I followed a guide I found on Virtuabotix and made a Bareduino. Works great and cost me about the same as a double cheeseburger!



What about power?

HATE TROLL TIM
Dec 14, 2006

MiNDRiVE posted:

What about power?

I just tap 3v3 from my RPi, but they have a guide for adding a regulator to the board if you want to power it from a 9V battery or something: https://www.virtuabotix.com/feed/?p=628

Personally, I'd skip it and just cut a USB cable and power it that way rather than putting a regulator onboard.

Edit: Just to note, I didn't buy a kit from them. I did buy a multi-pack of ATmega328's from them on Amazon. I already had all the other stuff, including a bunch of those cute tiny breadboards.

HATE TROLL TIM fucked around with this message at 07:03 on Mar 29, 2013

huhu
Feb 24, 2006

Vlad the Retailer posted:

What sort of peripherals/sensors do you have available?

One project that comes to mind is writing an emulator for an early microcomputer, like the SSEM or the Kenbak-1. The instruction set shouldn't take too long to implement, and the only components you need are switches and LEDs, plus a few multiplexers or shift registers depending on how many of those you add.
This whole event seems horribly mismanaged. Email announcement went out Wednesday for the event and evening preparation sessions on different coding languages and stuff started on Sunday. It looks like Arduino is the minority in this competition and most everything is computer programing sans hardware like Facebook Apps and such. Send emails to two of the coordinators and got no response.

Interesting suggestion you have but there's prizes and such at the end and the winners last year made crazy stuff that integrated with Google Maps to give you alternative routes around campus and such.

My ideas so far have included:
- Musical instrument(s) using various sensors
- Game similar to bop it
- Printer which uses several motors and a pen
- Somehow integrating the project with across the internet interaction

I've been limited so far in my designs because they're off of the stuff I already have. Will hopefully get an email before the competition starts or I'll just have to see what stuff they have available when I arrive. Will probably be checking into this thread several times from Saturday afternoon to Sunday afternoon.

huhu fucked around with this message at 04:14 on Mar 30, 2013

huhu
Feb 24, 2006
(Bumping back to relevance)

Making poo poo beautiful takes work.

Took me three hours to go from:



To:




:feelsgood:

MiNDRiVE
Nov 8, 2012
I really need to get some of those pre-made breadboard jumpers but I keep reading horror stories about how they smell like gas fill the house with the smell. Is this just a load of bs or do these things really smell that bad?

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

MiNDRiVE posted:

I really need to get some of those pre-made breadboard jumpers but I keep reading horror stories about how they smell like gas fill the house with the smell. Is this just a load of bs or do these things really smell that bad?
Its just solid core wire with insulation removed from the ends and bent. It smells like a wire...

Unless you are talking about running enough amps through them to burn the insulation off it, then it smells like a burning wire.

e: Or you mean the ones with the fancy molded ends? Those also smell like a wire.

MiNDRiVE
Nov 8, 2012

peepsalot posted:

Its just solid core wire with insulation removed from the ends and bent. It smells like a wire...

Unless you are talking about running enough amps through them to burn the insulation off it, then it smells like a burning wire.

e: Or you mean the ones with the fancy molded ends? Those also smell like a wire.

Yeah I guess they would smell like a wire but these reviews make me wonder...

Just read what that guy says

But whatever i'll pick up a 100 pack and sniff them until I pass out.

Adbot
ADBOT LOVES YOU

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

Not sure about that particular seller on amazon, but I got identical looking ones from some random ebay auction and have not noticed any strange smell.

Also they are a bit cheaper on ebay.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply