# iOS SDK digitalWrite not working \[Photon\]

**URL:** <https://community.particle.io/t/ios-sdk-digitalwrite-not-working-photon/59588>\
**Category:** iOS\
**Tags:** photon\
**Created:** [March 6, 2021, 2:09am UTC](https://community.particle.io/t/ios-sdk-digitalwrite-not-working-photon/59588 "2021-03-06T02:09:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![FA95](https://avatars.discourse-cdn.com/v4/letter/f/85f322/32.png) [@FA95](https://community.particle.io/u/FA95)\
**Post date:** [March 6, 2021, 2:09am UTC](https://community.particle.io/t/ios-sdk-digitalwrite-not-working-photon/59588/1 "2021-03-06T02:09:44Z")

</div>

Hello,

I had this issue before, but now with the new transition of SparkDevice to ParticleDevice, I am facing the same problem again. DigitalWrite doesn’t seem to work even following the documentation.  
Documentation \>\>\> [iOS SDK | Reference Documentation | Particle](https://docs.particle.io/reference/SDKs/ios/)

This is my code:

```auto
ParticleCloud.sharedInstance().login(withUser: userName, password: password) { (error:Error?) -> Void in
                    if let _ = error {
                        print("Wrong credentials or no internet connectivity, please try again")
                    }
                    else {
                        print("Logged in")
                        var myPhoton : ParticleDevice?
                        ParticleCloud.sharedInstance().getDevices { (devices:[ParticleDevice]?, error:Error?) -> Void in
                            if let _ = error {
                                print("Check your internet connectivity")
                            }
                            else {
                                if let d = devices {
                                    for device in d {
                                        myPhoton = device
                                        print(myPhoton!)
                                        let funcArgs = ["D7,HIGH"] as [Any]
                                        _ = myPhoton?.callFunction("digitalWrite", withArguments: funcArgs) { (resultCode : NSNumber?, error : Error?) -> Void in
                                            if (error == nil) {
                                                print("LED on D7 successfully turned on")
                                            } else {
                                                print("Error! \(String(describing: error))")
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

```

What am I doing wrong?

PS: Is there a github of an example app for swift. The current example file downloaded has only the particle setup code.

Thanks.

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [March 6, 2021, 8:16am UTC](https://community.particle.io/t/ios-sdk-digitalwrite-not-working-photon/59588/2 "2021-03-06T08:16:06Z")

</div>

We don’t know which firmware you are running on your devices but in Tinker the function is actually called `digitalwrite` with a lower case `w`.

---

<div class="post-metadata">

**Author:** ![FA95](https://avatars.discourse-cdn.com/v4/letter/f/85f322/32.png) [@FA95](https://community.particle.io/u/FA95)\
**Post date:** [March 6, 2021, 8:18pm UTC](https://community.particle.io/t/ios-sdk-digitalwrite-not-working-photon/59588/3 "2021-03-06T20:18:49Z")

</div>

Hello,

I tried the digitalwrite but still no luck. I do not know what version i’m using to be honest. But the error I get is:

**Optional(Error Domain=ParticleAPIError Code=400 “Timed out.” UserInfo={io.particle.error.localizedstring=Timed out., io.particle.error.response.body={**

**error = “Timed out.”;**

**ok = 0;**

**}, NSLocalizedDescription=Timed out.})**

EDIT:  
The device OS target (web IDE) is set to 2.0.1

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [March 7, 2021, 7:30am UTC](https://community.particle.io/t/ios-sdk-digitalwrite-not-working-photon/59588/4 "2021-03-07T07:30:47Z")

</div>

I just assumed you are running Tinker, but you haven’t really told us what code you are running in your `Particle.function()`?  
The cloud expects the return value to be sent back rather swiftly (~3sec) and if it doesn’t turn up by then (e.g. due to some delays in your function) it will report a timeout.

Have you tested your firmware with Console or CLI?

---

<div class="post-metadata">

**Author:** ![FA95](https://avatars.discourse-cdn.com/v4/letter/f/85f322/32.png) [@FA95](https://community.particle.io/u/FA95)\
**Post date:** [March 7, 2021, 10:39am UTC](https://community.particle.io/t/ios-sdk-digitalwrite-not-working-photon/59588/5 "2021-03-07T10:39:14Z")

</div>

It works through the IDE and also the application. I am using the documentation to call a function written by code to the Photon. There is no function that is stored in or written other than the one mentioned above. I am running this through XCODE in Swift language.
