Interaction between an iPhone App (made with Xcode) and the arduino wifi shield

Hello everybody !

Since 2 months, I learn how to use the original wifi shield made by arduino. Now, I learn communication between an iPhone app (build with Xcode) and arduino+arduino wifi shield. I realized a very instructive project : switch-on and switch-off a led by wifi. I found a very good tutorial (this link : Electronics for iPhone Developers Tutorial: Control a LED from your iPhone! | Kodeco ), and in this tutorial, I have learnt how to create an Xcode application and how to communicate with the arduino. In fact, you create a webserver, and you send information to this one. The arduino will read information and in function of them, it switch-on or switch-off the light.

Now I want to improve my knowledge. I would like to change the lightning of the led gradually. So, in Xcode I will use a "Slider" and send a message with value (between 0 and 255). I can collect the value of the "Slider" but I don't know the way to send this value to the arduino.
My problem is about the communication.

Maybe someone has tried ? If you have any tutorial or document about a project like mine, please contact me.

(PS : sorry for my english ...... )

Nicolas

Hi Nicolas,

I'm thinking of using Ray Wenderlichs tutorial for a Ethernet-arduino project as well. (But that will be during summerholidays i guess)

You could do the following starting from Ray's tutorial:

  • add a slider to the Storyboard
  • create an IBaction (ctrl drag from slider to .m file) & add a touch up outside routine or a ValueChanged routine:
  • multiply the value of the slider x 255
  • convert this integer into a string
  • add this string to: --- NSURL *url = [NSURL URLWithString:@"http://10.0.0.25/$addedstring"]; ---

Modify your arduino code so that the value of the added string is the value of a PWM signal at the output connected to the led.

I'm still a rooky myself in Xcode programming, but these could be basic steps. Also, there is a lot to find on stackoverflow.com on general Xcode programming.

Good luck!

Hi Nicolas,

I was wondering how you adapted the code of the ethernet shield to the wifi shield?

It would be great if you can post that code here :slight_smile:

Thanks in advance