Skip to content

Instantly share code, notes, and snippets.

// This is a comment - anything on a line after "//" is ignored
// by the computer.
/* This is also a comment - this one can be multi-line, but it
must start and end with these characters */
// You must "declare" variables before you use them,
// so that the program knows about them.
int ledPin1 = 7;
int ledPin2 = 8;
const int ledPin1 = 3;
const int ledPin2 = 4;
const int ledPin3 = 5;
const int ledPin4 = 6;
void setup() {
pinMode(ledPin1, INPUT);
pinMode(ledPin2, INPUT);
pinMode(ledPin3, INPUT);
pinMode(ledPin4, INPUT);
#include <Servo.h>
#include <math.h>
Servo myservo; // create servo object to control a servo
int potVal = 0; // variable to read the value from the analog pin
int processedPotVal = 0;
int photoVal; // variable to read the value from the photoresistor
const int ledPin1 = 3;
//
// YACViewController.m
// YetAnotherClone
//
// Created by Akmal Abdul Rahman on 12/3/14.
// Copyright (c) 2014 Akmal Abdul Rahman. All rights reserved.
//
#import "YACViewController.h"
@cowdinosaur
cowdinosaur / Tinkerbot 3.2
Last active August 29, 2015 14:06
Tinkerbot 3.2: Blinking an LED
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
@cowdinosaur
cowdinosaur / Tinkerbot 3.1
Last active August 29, 2015 14:06
Tinkerbot 3.1: Control an LED
int LED_PIN = 12;
// the setup routine runs once when you press reset:
void setup() {
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH);
delay(3000);
digitalWrite(LED_PIN, LOW);
}
@cowdinosaur
cowdinosaur / Tinkerbot 3.4
Last active August 29, 2015 14:06
Tinkerbot 3.4: Reading the value of a switch to control an LED
const int LIMIT_SWITCH_PIN = 12;
const int LED_PIN = 13;
void setup() {
pinMode(LIMIT_SWITCH_PIN, INPUT);
digitalWrite(LIMIT_SWITCH_PIN,HIGH);
pinMode(LED_PIN, OUTPUT);
}
@cowdinosaur
cowdinosaur / Tinkerbot 3.5
Created September 19, 2014 10:16
Tinkerbot 3.5: Controlling the proximity sensor
#include <NewPing.h>
const int ULTRASONIC_TRIGGER = 6;
const int ULTRASONIC_ECHO = 7;
#define MAX_DISTANCE 100
NewPing sonar(ULTRASONIC_TRIGGER, ULTRASONIC_ECHO, MAX_DISTANCE);
void setup() {
pinMode(ULTRASONIC_TRIGGER, OUTPUT);
@cowdinosaur
cowdinosaur / Tinkerbot 3.6.1
Created September 19, 2014 10:25
Tinkerbot 3.6.1: Controlling brightness of LED with proximity sensor
#include <NewPing.h>
const int ULTRASONIC_TRIGGER = 6;
const int ULTRASONIC_ECHO = 7;
const int LED_PIN = 11;
#define MAX_DISTANCE 100
NewPing sonar(ULTRASONIC_TRIGGER, ULTRASONIC_ECHO, MAX_DISTANCE);
@cowdinosaur
cowdinosaur / Tinkerbot 3.6.2
Created September 19, 2014 10:32
Tinkerbot 3.6.2: Controlling a buzzer with proximity sensor
#include <NewPing.h>
#include <NewTone.h>
const int ULTRASONIC_TRIGGER = 6;
const int ULTRASONIC_ECHO = 7;
const int BUZZER_PIN = 9;
#define MAX_DISTANCE 100
NewPing sonar(ULTRASONIC_TRIGGER, ULTRASONIC_ECHO, MAX_DISTANCE);