Presentation for Electronics 2.

Electronics 2c Presentation PDF

LM324op amp

Schmitt

IRF740 MOSFET

Code for square wave oscillator:

// code to make 500Hz square wave
int const outpin = 8;

void setup() {

pinMode(outpin, OUTPUT);
}

void loop() {
digitalWrite(outpin, HIGH);
delay(1);
digitalWrite(outpin, LOW);
delay(1);
}

 

Code for analog in to PWM out:

// code to make PWM out from analog in

int const input_pin = 0;
int const output_pin = 8;
int val1 = 0;
int val2 = 0;

void setup()
{
pinMode(output_pin, OUTPUT);
Serial.begin(9600);
}

void loop()
{
val1 = analogRead(input_pin);
val2 = val1 * 5 / (3.3 * 4);
Serial.print(“input = “);
Serial.print(val1);
Serial.print(” output = “);
Serial.println(val2);
analogWrite(output_pin, val2);
}