Two Plus Two Publishing LLC
Two Plus Two Publishing LLC
 

Go Back   Two Plus Two Poker Forums > >

Notices

Programming Discussions about computer programming

Reply
 
Thread Tools Display Modes
Old 10-12-2011, 12:50 AM   #1
mamafei
centurion
 
mamafei's Avatar
 
Join Date: Sep 2011
Location: Monkeying Around~!
Posts: 199
Programming arduino boards (C)

hey guys,

i was wondering if anyone here has any experience programming arduino microcontrollers or any type of microcontrollers with the C language.

It would be cool to network with some of you guys who have an interest in some engineering/programming.

I am someone who is competitive and likes to explore new technology and i feel that most engineers refuse to program and most programmers refuse to engineer.

I think arduinos are a great place for people to start and explore and if anyone here shares the same interest i'd like to send u a PM so we can discuss projects/applications sometime.
mamafei is offline   Reply With Quote
Old 10-12-2011, 05:09 AM   #2
kyleb
Carpal \'Tunnel
 
kyleb's Avatar
 
Join Date: Sep 2004
Location: Seattle
Posts: 39,036
Re: Programming arduino boards (C)

I want to get into this pretty bad, but I have like 200 projects I need to do first. I thought I was going to be developing wearable computing solution with Arduino, but I'm just going with a WiiMote and using the Bluetooth sending unit in it.
kyleb is offline   Reply With Quote
Old 10-12-2011, 02:11 PM   #3
myNameIsInga
adept
 
Join Date: Apr 2010
Location: Deep end of the player pool
Posts: 746
Re: Programming arduino boards (C)

Well I'm an engineer who loves programming, but just like kyleb I have a truck load of projects waiting to be completed, but if you have an interesting idea Im always open to doing new things.

Mvh
Inga
myNameIsInga is offline   Reply With Quote
Old 01-31-2012, 03:55 PM   #4
clowntable
Carpal \'Tunnel
 
clowntable's Avatar
 
Join Date: Jun 2006
Location: 39, 46, 56, 59, 191
Posts: 45,562
Re: Programming arduino boards (C)

Replying in this thread because I don't want to start a new one..

I randomly decided that I would like to know more about embedded systems. I have 0 clue about electronics which has always bothered me thus I want to fill that gap.

Googled/Wikied around a bit and it seems microcontrollers is what I'm after. Googled/Wikied a bit more to check out different architectures and stumbled upon the Arduino. I ordered a starter kit that included the Arduino Uno, a breadboard and a bunch of stuff like motor, leds off all kinds, resistors etc.
I have never soldered anything in my life so the idea of using a breadboard seems pretty nifty.

Since I really enjoyed the zeny aspect of reverse engineering and solving x86 "crackmes" (changing jump logic, 0x90ing stuff etc. pp nothing super advanced) back in the day I figured that's what I'll do except on a microcontroller level.

Done some further research while waiting for my order, seems like the Arduino uses an Atmel megaAVR 328...downloaded the datasheets and had a quick look.
Also wikied around more and found out it uses a (slightly modified) Harvard Architecture.

Downloaded AVR Studio (Windows only meh but no problem due to poker) and compiled a C program that did nothing (main just exits(0);'s), looked at the disassembly and hex file to get a good baseline. Turbobrowsed some ASM tutorial to get a rough grasp.

So basically now I know the AVR uses 32k Flash for Programm Memory, 32 general purpose registers+64 IO registers+2k SRam for Data Memory and a 1k EEPROM there's a CPU there are probably some buses and there's I/O (seems like 4 ports..A-D) that's basically the rough overview I have.
Arduino board just remaps the pins to be accessable in a better way (well grouped from a look at a photo of the board) + has a USB converter for the serial port (and power supply from that, autoreset for reprogramming some status led etc..basically just simplifying access to the microcontroller and adding peripherals)

Arduino kit should arrive tomorrow so I plan on just working through the sample projects to get a good highlevel feel and then I have a pretty simple "crackme" in mind that I want to build (and later extend it to a full fledged alarm system)
Arduino is different than programming the chip directly, they use a bootloader (2k of the 32k Flash are reserved for one) and some C-ish dialect instead of ANSI C.

How hard is it to desolder stuff from existing electronics btw, seems pretty nifty if I could eventually reuse some parts from elsewhere.
clowntable is offline   Reply With Quote
Old 02-01-2012, 02:52 AM   #5
DarkMagus
Carpal \'Tunnel
 
DarkMagus's Avatar
 
Join Date: Jul 2007
Location: Canada
Posts: 8,389
Re: Programming arduino boards (C)

i took a couple of classes on microcontrollers. i might be interested in doing this
DarkMagus is offline   Reply With Quote
Old 02-01-2012, 02:03 PM   #6
clowntable
Carpal \'Tunnel
 
clowntable's Avatar
 
Join Date: Jun 2006
Location: 39, 46, 56, 59, 191
Posts: 45,562
Re: Programming arduino boards (C)

Arrived today, played with it a bit. Arduino provides its own IDE and libraries so basically you're one layer removed from directly hacking the u-controller. Only built the first 4 projects from the PDF that came with the kit.

I also managed to build the crackme I was trying to go for and tested it, seems to work. I think I'll also play with buffer overflows a bit eventually.

If someone knows a simple tool to draw circuits let me know and I'll add the image. Circuit is really simple, red LED and green LED hooked up to pins 10 and 9 of the controller and ground, one 150 ohm resistor per led.

Code:
// Simple crackme, try to get the green light on and red light off
#define PASSWORD_SIZE 100
#define GOOD_PASSWORD "alice"

int redPin = 10;
int greenPin = 9;

char password[PASSWORD_SIZE] = "bob";

void setup() {
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
}

void loop() {
  if(strcmp(password,GOOD_PASSWORD)) {
    digitalWrite(greenPin, LOW);
    digitalWrite(redPin, HIGH);
  }
  else {
    digitalWrite(redPin, LOW);
    digitalWrite(greenPin, HIGH);
  }
}
As you can see basic Arduino code is a setup() for initialization of stuff and a loop() that acts like a game loop.
pinMode() and digitalWrite() are library functions provided by the Arduino framework. You can set a pin to input (for sensor data etc) or output. Lighting an LED obviously only requires output. digitalWrite is used to switch between HIGH (5V@40mA) and LOW (0V) so if it's set to low nothing flows in the circuit and thus the LED down't shine if it's set to high 5V@40mA flow through.

I'll finish all projects using Arduino only first then I'll recode the crackme stuff without the Arduino libraries. From reading one of the serial communication projects it seems I could add an "Enter PW" prompt over serial.

Next projects is some streetlights with a pushbutton, I think I'll just use that info to use the button to cycle through switching PWs between right and wrong for a bit of debugging.

Last edited by clowntable; 02-01-2012 at 02:14 PM.
clowntable is offline   Reply With Quote
Old 02-01-2012, 06:48 PM   #7
DarkMagus
Carpal \'Tunnel
 
DarkMagus's Avatar
 
Join Date: Jul 2007
Location: Canada
Posts: 8,389
Re: Programming arduino boards (C)

for a tool to draw circuits you could try http://www.linear.com/designtools/software/#LTspice

as for desoldering, you just need to get some desoldering wick. touch the wick to the solder, then melt the solder with your iron, and the solder should jump onto the wick. do it in a well ventilated area and be careful because the wick gives off fumes which are not good for you (although you should be doing this anyway any time you're working with solder)

or you can also get a desoldering pump which will suck the liquid solder out for you.
DarkMagus is offline   Reply With Quote
Old 02-02-2012, 01:39 AM   #8
clowntable
Carpal \'Tunnel
 
clowntable's Avatar
 
Join Date: Jun 2006
Location: 39, 46, 56, 59, 191
Posts: 45,562
Re: Programming arduino boards (C)

Thx for the info, upgraded my circuit to include a pushbutton and programmed it to toggle the password from the right to the wrong one and back.

Obviously been a while cince I coded C because it took me a couple of minutes to find a bug. I used == instead of strcmp() and the button never switched the PW back
The Serial.println() stuff I commented out was for debugging.

Circuit changed as well LDO, connected a pushbutton to pin 2.

Code:
// Simple crackme, try to get the green light on and red light off
#define PASSWORD_SIZE 100
#define GOOD_PASSWORD "alice"
#define BAD_PASSWORD "bob"

int redPin = 10;
int greenPin = 9;
int button = 2;

char password[PASSWORD_SIZE] = BAD_PASSWORD;

void setup() {
  //Serial.begin(9600);
  //Serial.flush();
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(button, INPUT);
}

void loop() {
  if(digitalRead(button) == HIGH) {
    strcpy(password,getNewPassword());
  }
  if(strcmp(password,GOOD_PASSWORD)) {
    digitalWrite(greenPin, LOW);
    digitalWrite(redPin, HIGH);
  }
  // strcpm returns 0 if the strings are equal
  else {
    digitalWrite(redPin, LOW);
    digitalWrite(greenPin, HIGH);
  }
  //Serial.println(password);
}

char* getNewPassword() {
  if(strcmp(password,GOOD_PASSWORD)) {
    return(GOOD_PASSWORD);
  }
  else {
    return(BAD_PASSWORD);
  }
}
clowntable is offline   Reply With Quote
Old 02-09-2012, 10:46 PM   #9
thunderchicken
journeyman
 
thunderchicken's Avatar
 
Join Date: Mar 2009
Posts: 211
Re: Programming arduino boards (C)

It's been about two years, but I spent a good $200 in arduino stuff. Very cool, a guy I worked with programmed some automatic thermostat for his fish tanks.

There were a few things I did, but never went too far with it. Really cool concept.
thunderchicken is offline   Reply With Quote
Old 07-01-2012, 10:37 AM   #10
saboy
newbie
 
Join Date: May 2006
Posts: 47
Re: Programming arduino boards (C)

For anyone interested, they founder of arduino just did a presentation on TED which was pretty interesting. Just ordered my kit yesterday, completely new to electronics and programming but it seems fun
saboy is offline   Reply With Quote
Old 07-03-2012, 04:48 AM   #11
Freakin
bacon wannabe
 
Freakin's Avatar
 
Join Date: Sep 2004
Posts: 17,153
Re: Programming arduino boards (C)

I got a pair of Raspberry Pi last week (suck it KyleB, not sharing like I promised) and I've been playing around with them. It's inspired me to bust out my arduino again, which I never did anything with the first time other than "Hello World" on a HD44870 LCD.

Got a fun idea for a project at work so I guess I'll post about it here whenever I get started. I'm in IT on an automation team that is largely going to measure success by how much money we save the company. I'm gonna rig the raspberry pi (would do arduino but ethernet shield alone is more than RPi itself) to poll a webpage (or run a splunk search) to get a $ amount, and every $10k saved it will trigger a Staples "Easy" button to go off. I'll probably end up getting the LCD going as well to get a running $ count.

Seems pretty manageable for a first project.

Second project is ambient lighting for TV using arduino.
Freakin is offline   Reply With Quote
Old 07-03-2012, 01:14 PM   #12
jmark
Pooh-Bah
 
jmark's Avatar
 
Join Date: Dec 2003
Location: US
Posts: 3,790
Re: Programming arduino boards (C)

Arduino is good for people who don't want to go into too much detail, but then I think you're missing out. PICs are great because you're working directly with the chip instead. Piclist.com is a great resource. Either way the little chips are a lot of fun.
jmark is offline   Reply With Quote
Old 07-03-2012, 03:42 PM   #13
clowntable
Carpal \'Tunnel
 
clowntable's Avatar
 
Join Date: Jun 2006
Location: 39, 46, 56, 59, 191
Posts: 45,562
Re: Programming arduino boards (C)

Mine's collecting dust, too much else to do. Kinda want to get a Raspberry Pi and do some OSDeving for fun. Seems like the perfect fit to get back into it. x86 is such a crappy architecture for that imo (yes I tried)
clowntable is offline   Reply With Quote
Old 07-06-2012, 09:54 AM   #14
adios
Carpal \'Tunnel
 
Join Date: Sep 2002
Location: Russian Troll
Posts: 21,459
Re: Programming arduino boards (C)

Quote:
Originally Posted by mamafei View Post
hey guys,

i was wondering if anyone here has any experience programming arduino microcontrollers or any type of microcontrollers with the C language.

It would be cool to network with some of you guys who have an interest in some engineering/programming.

I am someone who is competitive and likes to explore new technology and i feel that most engineers refuse to program and most programmers refuse to engineer.

I think arduinos are a great place for people to start and explore and if anyone here shares the same interest i'd like to send u a PM so we can discuss projects/applications sometime.
Not familiar with aduinos but I've done plenty of software development on microcontroller based apps in the past in both C and assembly language. I'm not up to speed on the current technology but I'm guessing lots more on chip memory available and lots more computing power these days.

Commercially what you'll find is a lot is orgs making an evaluation of what they need and negotiating prices with microcontroller vendors for masked ROM parts that are produced in quantity when the software/system is put into production. Also expect to have every resource used up that is available on the chip like memory. If you want to see "spaghetti" code" you'll get to see plenty on at least some projects (every project I've worked on anyway) with all kinds of shortcuts to save memory. Inevitably orgs want to incorporate as many features as possible into their microcontroller based system. You need to understand hardware/software interfaces and be able to read spec sheets to get started in coding the interfaces to various components like timer/event counters, etc. You'll probably need to understand and code interrupt service routines.

Also most of the time you're going to be "rolling your own" as far as on OS is concerned. You're certainly not going to be writing a full blown OS but you typically will be designing and implementing a control program to at least sync up various real-time software tasks. You'll be working a lot with hardware developers to in specifying interfaces. It's really a lot of fun.

Last edited by adios; 07-06-2012 at 10:03 AM.
adios is offline   Reply With Quote
Old 07-12-2012, 06:17 PM   #15
YouR_DooM
Carpal \'Tunnel
 
YouR_DooM's Avatar
 
Join Date: Jul 2009
Location: facepalming my way into history
Posts: 7,780
Re: Programming arduino boards (C)

So I'd like to buy my father an arduino set so he has something to do.

Is this the correct way to start?

http://www.watterott.com/de/Arduino-Uno
http://www.watterott.com/de/Arduino-...d-Workshop-Kit

Do I need other stuff se he can take 2 months to make a few lights blink ?

edit: I also like how I have trouble finding an italian product in italy. Pretty LOL.

Last edited by YouR_DooM; 07-12-2012 at 06:23 PM.
YouR_DooM is offline   Reply With Quote
Old 07-12-2012, 09:24 PM   #16
Freakin
bacon wannabe
 
Freakin's Avatar
 
Join Date: Sep 2004
Posts: 17,153
Re: Programming arduino boards (C)

Yeah that's a good setup. Mainstream arduino, breadboard, jumper wires and an assortment of electronics. Should let him pick up most beginner arduino books and do the majority of the experiments

could also consider a character LCD, cause it's fun to make your arduino tell you stuff. one of the 5v 16x2 character displays based on the HD44780 makes it dead simple. Once you have the pins defined it's as easy as
Code:
lcd.print("hello, YouR_DooM!");
Freakin is offline   Reply With Quote
Old 12-17-2018, 12:18 AM   #17
weevil
veteran
 
Join Date: Dec 2004
Location: teh suck
Posts: 2,114
Re: Programming arduino boards (C)

Looking at this Arduino starter kit to play around with. Any people still playing with these?
weevil is offline   Reply With Quote
Old 12-17-2018, 01:25 PM   #18
RustyBrooks
Carpal \'Tunnel
 
RustyBrooks's Avatar
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 24,289
Re: Programming arduino boards (C)

I do a fair amount of microcontroller stuff, including some arduino and arduino compatible systems. The stuff I'm working with these days are mostly

* teensy: https://www.pjrc.com/store/ - medium price, very small, fairly powerful/great feature set. They have a lot of native support for interesting stuff. I use them for when I need USB HID support, or USB host support, or for MIDI input (although a lot of arduino stuff should support MIDI)

* ESP8266 and ESP32 - these are little devices that have built in wifi. They are supported by the arduino dev environment but have some idiosyncracies. They're small and very cheap though. Another nice thing about these is once you get them set up you can deploy to them over WIFI (however, if you mess up your program you can sort of brick them and have to reflash them over USB again)

I avoid the arduino IDE when possible - it has some very annoying things to it. It's a pain to develop without it though. My advice is to make basically a blank .INO file and do all your code in CPP files. This way you can develop outside of the IDE but use the IDE to compile and deploy.
RustyBrooks is offline   Reply With Quote
Old 12-17-2018, 02:11 PM   #19
RustyBrooks
Carpal \'Tunnel
 
RustyBrooks's Avatar
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 24,289
Re: Programming arduino boards (C)

As far as kits and things go, they're fine, but you'll also find all the stuff in kits much cheaper individually on amazon, or even cheaper from china, via someplace like banggood.com. With amazon, you'll pay a bit more to get it soon and with bangood suuuuuper cheap but it will be weeks until you get delivery. Like, I ordered a bunch of stuff from banggood on thanksgiving day and it's starting to trickle in now. But just amazingly cheap, like, 100 SMD micro switches for 3 bucks, etc. If I go to, say, Frys, I can buy them for, I dunno, $1 each.

There are some things you may need to get soonish, depending on what microcontroller you use - a lot of modern MCUs use 3.3v but a lot of peripherals are still 5v, so you'll need voltage regulators and logic-level converters. You can buy little boards of these from amazon or sparkfun or anywhere really, pretty cheap. You'll want some breadboards, and you'll probably want a breadboard power supply, like these, they're super handy:
https://www.amazon.com/gp/product/B0...?ie=UTF8&psc=1

The rest of the stuff you'll figure out what you need as you come across it, I guess. I've been doing electronics off and on for a long time so I have a ton of stuff.
RustyBrooks is offline   Reply With Quote
Old 12-19-2018, 12:09 AM   #20
weevil
veteran
 
Join Date: Dec 2004
Location: teh suck
Posts: 2,114
Re: Programming arduino boards (C)

Thanks for the suggestions. Price isn't really a concern, I have no idea what I need or even really what I want to do, which is why I went with a kit with a tutorial book and a bunch of parts and sensors. I guess I envision making some little useful contraptions to solve basic household problems or just as fun exercises, like a real world manifestation of some Zachtronics game problems.
weevil is offline   Reply With Quote
Old 01-12-2019, 01:31 AM   #21
Ryanb9
Carpal \'Tunnel
 
Ryanb9's Avatar
 
Join Date: Aug 2006
Location: NEVA!
Posts: 7,086
Re: Programming arduino boards (C)

Quote:
Originally Posted by mamafei View Post
hey guys,

i was wondering if anyone here has any experience programming arduino microcontrollers or any type of microcontrollers with the C language.

It would be cool to network with some of you guys who have an interest in some engineering/programming.

I am someone who is competitive and likes to explore new technology and i feel that most engineers refuse to program and most programmers refuse to engineer.

I think arduinos are a great place for people to start and explore and if anyone here shares the same interest i'd like to send u a PM so we can discuss projects/applications sometime.
i got my degree in software development from bsu ~ 2 years ago and Ive worked for an investment analytics company since. I got into arduino's about 1 year ago. I currently own about 5 Uno's, a duo, a few mega's, and 1 or 2 nano's that I seem to have acquired over the last year. Recently I started using an intelij plugin to allow remote code to be sent to a rasberrypi + pi4j and a rasberry pi. Now, I can write code in java, use pi4j and a i/o port expander to control an infinite number of i/o pins using i2c. The only time I would use arduino is if I finished a project on my rasberry pi and was ready to go from prototype to production. Imo, there is no reason to program in C and use only 2kb of memory or worry about an EEPROM when you are doing a fun project and making your own kitchen egg timer on a 4x20 LCD. You should instead use rasberry pi + intellij + pi4j and java language for that project and give 2 ****s about memory or performance. Have fun with it. If later you decide to make a prototype that might go to production, THEN you should start programming on arduino and in C language and start worrying about memory and performance and cost.

That being said, If I had to do it over again, I would start with arduino uno, do ~4 different projects that I found online. 2 in aruino IDE in windows and 2 using atom + platformio on an ubuntu box (search "dual boot ubuntu with windows" to get that setup). Then i would switch to doing ~4 different projects (from tutorials I found online) using intellij + pi4j + java 8 + the intellij plugin that lets you run on your rasberry pi that can even be headless.

When I say "that being said I'd do..." I mean if I was me. I'm trying to take ideas in my head and turn them into prototypes to try to make some money. If I was instead interested in just messing around and having fun with hardware using my programming skills, i'd skip C in arduino and skip python in rasberry pi and go strait to pi4j and rasberry pi 3b+ with 64g disk and intellij and have a blast.
Ryanb9 is offline   Reply With Quote

Reply
      

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Forum Jump


All times are GMT -4. The time now is 06:13 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright 2008-2017, Two Plus Two Interactive
 
 
Poker Players - Streaming Live Online