This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define LED 6 // LED output pin = ~6 | |
| void setup() { | |
| // put your setup code here, to run once: | |
| pinMode(7, OUTPUT); | |
| } | |
| void loop() { | |
| // put your main code here, to run repeatedly: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //: Playground - noun: a place where people can play | |
| import UIKit | |
| import CoreLocation | |
| let lincolnMemorialLocation = CLLocation(latitude: 38.889553, longitude: -77.050176) | |
| let capitolBuildingLocation = CLLocation(latitude: 38.890173, longitude: -77.009061) | |
| let distance = lincolnMemorialLocation.distance(from: capitolBuildingLocation) | |
| // distance will be calculated as 3567.82356314919 meters |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import UIKit | |
| extension UIView { | |
| func addBorder(width: CGFloat, radius: CGFloat, color: UIColor) { | |
| self.layer.borderWidth = width | |
| self.layer.borderColor = color.cgColor | |
| self.layer.cornerRadius = radius | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define RED_PIN 3 // no need for equal. Don't use a semi-colon | |
| #define BLUE_PIN 6 | |
| #define GREEN_PIN 5 | |
| #define RED_BUTTON 7 | |
| int buttonState = 0; | |
| // the setup function runs once when you press reset or power the board | |
| void setup() { | |
| // initialize digital pin LED_BUILTIN as an output. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define RED_PIN 3 // no need for equal. Don't use a semi-colon | |
| #define BLUE_PIN 6 | |
| #define GREEN_PIN 5 | |
| #define RED_BUTTON 7 | |
| #define GREEN_BUTTON 8 | |
| #define BLUE_BUTTON 9 | |
| int redButtonState = 0; | |
| int greenButtonState = 0; | |
| int blueButtonState = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var rating = 0 { | |
| didSet { | |
| for starButton in starButtonCollection { | |
| let image = UIImage(named: (starButton.tag < rating ? "star-filled": "star-empty")) | |
| starButton.setImage(image, for: .normal) | |
| } | |
| review.rating = rating | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func saveData(spot: Spot, completed: @escaping (Bool) -> ()) { | |
| let db = Firestore.firestore() | |
| // Create the dictionary representing the data we want to save | |
| let dataToSave = self.dictionary | |
| // if we HAVE saved a record, we'll have a documentID | |
| if self.documentID != "" { | |
| let ref = db.collection("spots").document(spot.documentID).collection("reviews").document(self.documentID) | |
| ref.setData(dataToSave) { (error) in | |
| if let error = error { |