Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

int radius = 0;

float area;

void setup()

Serial.begin(9600);

void loop()

radius = radius + 1;

area = radius * radius * 3.14;

Serial.print("A circle with radius ");

Serial.print(radius);

Serial.print(" has an area of ");

Serial.println(area);

delay(1000);

//////////////////////////////////////////////////////////////////////////////////////////////////////////
int led = 13; // connect LED to pin 13

int pin = 7; // connect pushbutton to pin 7

int value = 0; // variable to store the read value

void setup()

pinMode(led, OUTPUT); // set pin 13 as output

pinMode(pin, INPUT); // set pin 7 as input

void loop()

{
value = digitalRead(pin); // set value equal to the pin 7 input

digitalWrite(led, value); // set LED to the pushbutton value

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////

int led = 13; // connect LED to pin 13

int pin = 0; // potentiometer on analogy pin 0

int value = 0; // variable to store the read value

void setup()

void loop()

value = analogRead(pin); // set value equal to the pin 0’s input

value /= 4; // converts 0-1023 to 0-255

analogWrite(led, value); // output PWM signal to LED

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////

const int potPin = A0; // select the input pin for the potentiometer

const int ledPin = LED_BUILTIN; // select the pin for the LED

int val = 0; // variable to store the value coming from the sensor

void setup()

pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT

void loop()

val = analogRead(potPin); // read the voltage on the pot

digitalWrite(ledPin, HIGH); // turn the ledPin on

delay(val); // blink rate set by pot value (in milliseconds)

digitalWrite(ledPin, LOW); // turn the ledPin off

delay(val); // turn led off for same period as it was turned on

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/

You might also like