Jump to content


Photo

Arduino + Game Maker


  • Please log in to reply
26 replies to this topic

#1 Buff-Robotix

Buff-Robotix

    Who Took My Pants!?!

  • GMC Member
  • 309 posts

Posted 02 February 2012 - 01:49 AM

This may be in the wrong forum, and might get moved...

At long last I am finally able to connect Game Maker and Arduino seamlessly through the RS232 DLL by andbna. Today I share this with you.
I have made an example that includes how to write bytes to the Arduino and how to read bytes from it. You must be fairly fluent in the Arduino language in order to use this technique effectively.
Included in the following download is the gmk (GM8) example, the RS232 DLL and gml scripts for it, and the Arduino pde file.

Download

The technique makes use of the RS232_WriteByte() function to write to the Arduino and Arduino's Serial.read() function to read from Game Maker.
Similarly it uses Arduino's Serial.print() function to write to Game Maker and RS232_ReadByte() to read from the Arduino.
You can also use RS232_ReadString() to read strings from the Arduino and RS232_WriteString() to write strings to the Arduino.

Using this example
  • First open up the GMBlink.pde in your Arduino programing program. Read and understand it.
  • Download the sketch to your Arduino.
  • Then open up the Arduino_Blink.gmk in Game Maker. Read and understand it.
  • Now find the port your Arduino is plugged into, this can be found in the device manager.
  • Change the com variable to your COM port.
  • Then run the game and you should be able to control your Arduino's LED with the spacebar.
With this new expansion of Game Maker we can effectively connect our computers to the real world with sensors and motors and such.
Game Maker is so versatile and easy we can easily prototype Arduino programs very quickly.

For more information about the Arduino visit their website.
For more information abut the RS232 DLL and for the extension go here. Credit goes to andbna for this awesome DLL

If you have any questions just comment.
I have only tested this on my Arduino Duemilanove and I would like to see if it works on others too, so please test it if you have an Arduino.

Enjoy,
RobotiX

Edit: *Link updated 2/22/13

Edited by Buff-Robotix, 22 February 2013 - 07:52 PM.

  • 1

#2 getty

getty

    GMC Member

  • New Member
  • 16 posts
  • Version:Unknown

Posted 02 February 2012 - 02:32 AM

That's amazing! I've been planning to use arduino for a while now. I will be using this, definitely.
  • 0

#3 c_stallworth

c_stallworth

    GMC Member

  • New Member
  • 5 posts
  • Version:GM8

Posted 08 February 2012 - 06:56 AM

This seems to be what I need. However, I click on Download and get Chinese. How can I get your files? Please help.
  • 0

#4 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14392 posts
  • Version:GM:Studio

Posted 08 February 2012 - 07:37 AM

This seems to be what I need. However, I click on Download and get Chinese. How can I get your files? Please help.

Works fine now
  • 0

#5 c_stallworth

c_stallworth

    GMC Member

  • New Member
  • 5 posts
  • Version:GM8

Posted 08 February 2012 - 08:00 AM

Forgive my mistake, I was using the wrong character set. I have everything installed and understand the code, but can't get the communication going.
  • 0

#6 c_stallworth

c_stallworth

    GMC Member

  • New Member
  • 5 posts
  • Version:GM8

Posted 08 February 2012 - 08:04 AM

My Arduino is connected to com port 37. I change the value of the com variable in the code for the create event, but to no avail.
  • 0

#7 c_stallworth

c_stallworth

    GMC Member

  • New Member
  • 5 posts
  • Version:GM8

Posted 08 February 2012 - 08:33 AM

My Arduino is connected to com port 37. I change the value of the com variable in the code for the create event, but to no avail.


Changed the port number of the Arduino to 4 and I am now able to communicate from GM to the Arduino. However, I am not successful when I try to open the serial monitor in my Arduino programming environment to try to communicate from the Arduino to GM. I get the error message 'Serial port 'COM4' already in use. Try quitting any programs you may be using.'. Please assist. Thank you.
  • 0

#8 c_stallworth

c_stallworth

    GMC Member

  • New Member
  • 5 posts
  • Version:GM8

Posted 08 February 2012 - 08:46 AM


My Arduino is connected to com port 37. I change the value of the com variable in the code for the create event, but to no avail.


Changed the port number of the Arduino to 4 and I am now able to communicate from GM to the Arduino. However, I am not successful when I try to open the serial monitor in my Arduino programming environment to try to communicate from the Arduino to GM. I get the error message 'Serial port 'COM4' already in use. Try quitting any programs you may be using.'. Please assist. Thank you.


Persistence has won out. I now understand my errors and realize that the application was working properly. Input from the serial monitor was not needed. I can now go to bed with visions of coolness dancing in my head. Thank you for sharing this.
  • 0

#9 Buff-Robotix

Buff-Robotix

    Who Took My Pants!?!

  • GMC Member
  • 309 posts

Posted 10 February 2012 - 09:12 PM

I'm sorry I wasn't here to help you and I'm glad everything ironed itself out.
It is true that you cannot open up the Arduino Serial Command window while you are connected to the Arduino with GM or anything else for that matter, only one program can be connected to the Arduino at a time. Any communication from the Arduino must be downloaded before hand and triggered by GM.

I'm glad everyone is getting it to work and having a good time. I think some really cool ideas will come from this.

RobotiX
  • 0

#10 Techno-Q

Techno-Q

    GMC Member

  • GMC Member
  • 7 posts
  • Version:GM8.1

Posted 04 November 2012 - 10:59 PM

I'm Sorry, this post is an error!

Edited by Techno-Q, 14 November 2012 - 10:00 PM.

  • 0

#11 Techno-Q

Techno-Q

    GMC Member

  • GMC Member
  • 7 posts
  • Version:GM8.1

Posted 14 November 2012 - 12:19 PM

I'm Sorry, this post is an error!

Edited by Techno-Q, 14 November 2012 - 10:01 PM.

  • 0

#12 Techno-Q

Techno-Q

    GMC Member

  • GMC Member
  • 7 posts
  • Version:GM8.1

Posted 14 November 2012 - 12:28 PM

I'm Sorry, this post is an error!

Edited by Techno-Q, 14 November 2012 - 10:02 PM.

  • 0

#13 Tarik

Tarik

    GMC Member

  • GMC Member
  • 2469 posts
  • Version:GM:Studio

Posted 15 November 2012 - 04:34 AM

Sweet! Might be time to stop checking out Arduino videos and building one myself haha. Could build a dedicated controller for my games :P

Thanks a lot for your efforts. I hope to return sometime soon. Would you keep us up to date on your endeavours?
  • 0

#14 Techno-Q

Techno-Q

    GMC Member

  • GMC Member
  • 7 posts
  • Version:GM8.1

Posted 15 November 2012 - 05:13 AM

OK, I have loaded the arduino with the blink sketch. I have opened the Blink.gmk inGM8.1., and ran the program. The room comes up and responds to the keybord.

However the light on the Arduino is not responding to the commands. My com port is set to 4.
I know the arduino is working because it works with other sketiches.
I don’t think that I am connected, Or am I?

Anyone know what I should try next?
  • 0

#15 AmirBayareh

AmirBayareh

    GMC Member

  • New Member
  • 3 posts
  • Version:GM8

Posted 24 February 2013 - 07:06 AM

Hello, I have a problem, I can't get the device to work properly, any time I try to set the modes for the blink the only light that flashes is the one labeled "RX".
The COM ports are fine, already changed the number to the COM the Arduino is connected to.
If someone could please help me, I would apreciate that so much!
:laugh:/>
  • 0

#16 Buff-Robotix

Buff-Robotix

    Who Took My Pants!?!

  • GMC Member
  • 309 posts

Posted 24 February 2013 - 07:09 AM

Hey Amir,What kind of Arduino do you have? Does it have an led hooked up to digital pin 13?
  • 0

#17 BluebirdoBluB

BluebirdoBluB

    GMC Member

  • New Member
  • 6 posts
  • Version:GM8.1

Posted 27 February 2013 - 02:36 AM

Hi all,

This interface looks awesome, but does anyone know if it can work with Game Maker Studio? I have the free version through Steam, but it gave some error messages about opening old game maker files. I know some free versions have restrictions on custom DLLs, and I'd like to be sure what I can use this with, before I commit to buying anything if necessary.

Thanks!
  • 0

#18 AmirBayareh

AmirBayareh

    GMC Member

  • New Member
  • 3 posts
  • Version:GM8

Posted 27 February 2013 - 05:33 AM

Hey Amir,What kind of Arduino do you have? Does it have an led hooked up to digital pin 13?

Hello there, I have the Arduino UNO, and I finally got it working, thank you so much for the reply =), the problem was that I didn't set the serial Number in every function, now I got to control a servomotor trough Game Maker, and even build a minigame that showed the enemy health bar as an array of leds.
  • 0

#19 Buff-Robotix

Buff-Robotix

    Who Took My Pants!?!

  • GMC Member
  • 309 posts

Posted 27 February 2013 - 06:05 AM

That's great Amir! Some practical implementations. If you are willing to share I'd be interested on how you transferred the data. I used to be able to do strings just fine with Serial.print("Hello world"); and RS232_ReadString(11,1); but I have been running into problems and currently the only reliable form of communication I can achieve is sending bytes which is incredibly limited. I think its about time I get an UNO, my Duemilanove is getting pretty old.

BluebirodBluB: I know that many dlls do not work with studio. I will give it a shot and see what I come up with.

RobotiX

Edited by Buff-Robotix, 27 February 2013 - 07:57 AM.

  • 0

#20 AmirBayareh

AmirBayareh

    GMC Member

  • New Member
  • 3 posts
  • Version:GM8

Posted 28 February 2013 - 04:34 AM

That's great Amir! Some practical implementations. If you are willing to share I'd be interested on how you transferred the data. I used to be able to do strings just fine with Serial.print("Hello world"); and RS232_ReadString(11,1); but I have been running into problems and currently the only reliable form of communication I can achieve is sending bytes which is incredibly limited. I think its about time I get an UNO, my Duemilanove is getting pretty old.

BluebirodBluB: I know that many dlls do not work with studio. I will give it a shot and see what I come up with.

RobotiX


I would be pleased to share what I have done until now ^^, but I won't be available until this weekend, so I'll share the code and some instructions for the arduino maybe on saturday. I also have some problemas too for reading some chars from serial ports, but we may find a solution for this issues =)
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users