Welcome back to 12 Days of Arduino Day 10. Today we finish the core and connect to a remote computer via bluetooth. Everything has been pretty simple up until this point, so if you are a beginner you might want to watch some tutorials on YouTube and read up on the HC-05 and HC-06 before-hand.
Parts:
-Arduino Uno R3
-Motor
-Fan
-Jumper Wires
-Breadboard
-Spam Can
-2x TIP120 transistors
-HC-05 or HC-06
#include <SoftwareSerial.h>
#define rxPin 0
#define txPin 1
int motor = 3;
int fan = 5;
int incomingByte = 0;
SoftwareSerial bluetooth(rxPin, txPin);
void setup() {
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
pinMode (motor, OUTPUT);
pinMode (fan, OUTPUT);
bluetooth.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
if(bluetooth.available()>0){
bluetooth.print("I received: ");
bluetooth.println(incomingByte, DEC);
}
analogWrite (motor, 255);
digitalWrite (fan, HIGH);
delay(1000);
}
Pro Tip: If you have issues uploading your sketch, unplug the Bluetooth module from the rx/tx pins.
Support future projects by visiting our affiliate ICStation for electronics components: