Jump to content




Q: Arduino control over serial interface

awesome duhh tutorial

  • Please log in to reply
9 replies to this topic

#1 floris2burn

floris2burn

    Software Engineer

  • 414 posts

Posted 13 July 2011 - 10:09 AM

Hi, does anyone know how to control your arduino over the serial interface?
I believe someone found some program that lets you do something over the serial connection, but I can't remember the name.

Any help please?

Posted ImagePosted Image


#2 coastercrazy10

coastercrazy10

    Mad Scientist

  • 7008 posts

Posted 13 July 2011 - 10:24 AM

Why wouldn't you just use USB? It's technically serial (Universal Serial Bus) and the actual serial port is legacy. I was under the impression the Arduinos were intended for USB too...

-Ben

SSCoasters Staff | The SSCoasters Forum Rules
University of Illinois at Urbana Champaign | Computer Science & Mathematics
Posted Image
Fireball | Kingda Ka | Inclination | Diamondback


#3 floris2burn

floris2burn

    Software Engineer

  • 414 posts

Posted 13 July 2011 - 10:28 AM

Maybe I formulated my question wrong.
The arduino is indeed connected with the usb to the computer. However, when in the arduino environment, it is possible to start a "serial connection". With this your arduino can write data to the pc and the pc will read it out and show it in a textbox.

However, I believe there are programs which can easilly send/receive data using this protocol and even allow you to create your own "program". For instance, a screen with buttons that allow you to send a certain "data bit" and "lights (graphics)" that change to the information received.

Posted ImagePosted Image


#4 Jogumpie

Jogumpie

    Living through the great Gump hiatus...

  • 13586 posts

Posted 13 July 2011 - 10:37 AM

I believe Max called something like this 'Processing'. Better look into that.


SSCoasters Administrator
The SSCoasters Forum Rules
DD_signature.jpg
YoutubeButton.pngFacebookButton.png


#5 coastercrazy10

coastercrazy10

    Mad Scientist

  • 7008 posts

Posted 13 July 2011 - 10:49 AM

Ah, I gotcha.

So basically you're looking for a way to dynamically send instructions to your Arduino without having to "hard code" anything, i.e. you want to activate/deactivate individual pins on the fly from a user-interface? I'm sure something like this exists but it would be good practice to write one yourself I think (not to mention rewarding as you'd likely learn a fair bit).

In C++/what i can make of arduino language the program could be done on the command line somewhat simply, like this:

int main(int argc, char *argv[])
{
    int input;
    int state;
    while scanf("%d", input)
    {
        switch(input)
        {
            case 0
            {
                state = digitalRead(0)
                if state = 0
                    digitalWrite(0, HIGH)
                else //state = 1
                    digitalWrite(0, LOW)
            }
            case 1
                //repeat case 0 info changing the 0s to proper numbers
            case 2
                //repeat case 0 info changing the 0s to proper numbers
            case 3
                //repeat case 0 info changing the 0s to proper numbers
            case 4
                //repeat case 0 info changing the 0s to proper numbers
            case 5
                //repeat case 0 info changing the 0s to proper numbers
            case 6
                //repeat case 0 info changing the 0s to proper numbers
            case 7
                //repeat case 0 info changing the 0s to proper numbers
            case 8
                //repeat case 0 info changing the 0s to proper numbers
            case 9
                //repeat case 0 info changing the 0s to proper numbers
            case 10
                //repeat case 0 info changing the 0s to proper numbers
            case 11
                //repeat case 0 info changing the 0s to proper numbers
            case 12
                //repeat case 0 info changing the 0s to proper numbers
            case 13
                //repeat case 0 info changing the 0s to proper numbers
            case 14
                //repeat case 0 info changing the 0s to proper numbers
            case 15
                //repeat case 0 info changing the 0s to proper numbers
        }
    }
}

Hope this is what you're looking for/helps. It's not going to be plug and play but here's the general idea of what you seem to be wanting.

-Ben

SSCoasters Staff | The SSCoasters Forum Rules
University of Illinois at Urbana Champaign | Computer Science & Mathematics
Posted Image
Fireball | Kingda Ka | Inclination | Diamondback


#6 floris2burn

floris2burn

    Software Engineer

  • 414 posts

Posted 13 July 2011 - 10:58 AM

I think what Jogumpie remembered what I was looking for.

coastercrazy, it's somewhat like you described. But I'd prefer to send variables to the arduino and let the arduino handle what to do with it.
(For instance, you have a manual/auto bit, when in manual, it reeds the variables that are being sent by the pc and uses them to do it's thing.)

Posted ImagePosted Image


#7 floris2burn

floris2burn

    Software Engineer

  • 414 posts

Posted 14 July 2011 - 05:47 PM

Ok, so maybe "serial communication" would've been better than "interface".

However, I've been working with the Processing software all day and managed to make 2 boxes that work as switches. When the first one - Brakes - is clicked, it is turned 'on' and the arduino will switched the output high. Then it can be switched off again.
Did the same thing for attaching the motor.

So if anyone is interested, I can give you more information about it. For now, pictures!

Posted Image

http://www.sscoaster...mmunication.bmp


I know it's mostly just bit's n pieces of code in the pictures, but they're not meant as a guide.
Could try to a video of some sort...

Posted ImagePosted Image


#8 Maxlaam

Maxlaam

    Tracing Tyrant's Steps

  • 8116 posts

Posted 17 July 2011 - 04:48 PM

Floris, you are my hero! I gave up on this because I couldn't figure out to properly make button work on a click signal. I have to say but I really disliked the documentation on processing combined with the Arduino!

Maybe you can teach me how to make those buttons! Kuddos!


SSCoasters Administrator
Read The Forum Rules(smart)

Posted Image
Posted ImagePosted Image


#9 floris2burn

floris2burn

    Software Engineer

  • 414 posts

Posted 18 July 2011 - 10:30 AM

It's different than programming with the arduino, but the syntax is almost identical. (Based on C#.) One major difference is that arduino scans the program from start to end and work out the actions. Processing is dependent of actions and such, so different things parts of the code are executed through each other.

I don't mind explaining some of the things I managed so far. But I only have this little bit of program, got to redo a part of the communication to make it more flexible and advanced.

Cheers

Posted ImagePosted Image


#10 floris2burn

floris2burn

    Software Engineer

  • 414 posts

Posted 20 July 2011 - 03:45 PM

Dubbelpost, but I don't care.

I made a little video on the stuff it does so far, but it was made using the webcam and bad lighting. So some colors are a bit off on the monitor, and had to go pretty close-up.

Anyway: http://www.youtube.c...h?v=JgE8g6FhAVc

Posted ImagePosted Image






Also tagged with one or more of these keywords: awesome, duhh, tutorial