You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
2 days ago | |
---|---|---|
my-tclab-firmware | 2 days ago | |
Readme.md | 3 days ago | |
main.ipynb | 2 days ago |
Readme.md
Introduction
Basic
Digital outputs
#include <Arduino.h>
// vars and pins
const int led = 9;
void setup() {
// put your setup code here, to run once:
pinMode(led, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(led, LOW);
delay(500);
digitalWrite(led, HIGH);
delay(500);
}
PWM outputs
#include <Arduino.h>
// vars and pins
const int led = 9;
void setup() {
// put your setup code here, to run once:
pinMode(led, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.print("pwm on\n");
for(int pwm=0; pwm<=255; pwm+=5){
analogWrite(led, pwm);
delay(50);
}
Serial.print("pwm off\n");
for(int pwm=255; pwm>=0; pwm-=5){
analogWrite(led, pwm);
delay(50);
}
}
Analog readings
#include <Arduino.h>
// vars and pins
const int led = 9;
const int T2 = A2;
int T2Val;
void setup() {
// put your setup code here, to run once:
//pinMode(led, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
T2Val = analogRead(T2);
Serial.print("ADC: ");
Serial.println(T2Val);
delay(100);
}