LED Control in swift with arduino and XCODE

  1. 8 months ago

    Hello!,
    can someone help me with this code???
    i'm traying to write this in code in swift. im programming a code for a control a LED - Light via Ethernet with Xcode OS X and arduino!

    if someone have a tip, let me know!
    thank.
    the code is the following one:
    import Cocoa

    class ViewController: NSViewController {

    override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
    }

    override var representedObject: AnyObject? {
    didSet {
    // Update the view, if already loaded.
    }
    }

    @IBAction func ButtonON(sender: AnyObject) {

    // turn the LED on
    NSURL *url = [NSURL URLWithString:@"http://192.168.178.50/$1"];
    NSURLRequest *req = [NSURLRequest requestWithURL:url];
    [myWebView loadRequest:req];
    }

    @IBAction func ButtonOFF(sender: AnyObject) {

    // turn the LED off
    NSURL *url = [NSURL URLWithString:@"http://192.168.178.50/$2"];
    NSURLRequest *req = [NSURLRequest requestWithURL:url];
    [myWebView loadRequest:req];

    }
    }

or Sign Up to reply!