Search This Blog

Translate

Showing posts with label Tutorial. Show all posts
Showing posts with label Tutorial. Show all posts

Thursday, 21 August 2014

Auto bed levelling for RepRap Prusa Mendel i2

I have heard a lot of people in the RepRap community talking about how they have set up auto bed levelling, however most of the designs they use are for use on a RepRap Prusa i3. So I thought I would share with you my 3d printed design to hold the servo and z probe end stop. So here are the two designs: http://www.thingiverse.com/thing:432232.

I then followed this tutorial:

Part One: http://zennmaster.com/random-things/auto-bed-leveling-for-the-makerfarm-prusa-i3-part-1-assembly-and-basic-setup

Part Two: http://zennmaster.com/random-things/auto-bed-leveling-for-the-makerfarm-prusa-i3-part-2-setting-up-marlin

Part Three: http://zennmaster.com/random-things/auto-bed-leveling-for-the-makerfarm-prusa-i3-part-3-final-setup

This is for an i3 but the setup is very similar! Please see Thingiverse link for pictures and feel free to ask any questions you may have.

Thursday, 14 August 2014

RepRap 3Dprinter stepper calibration - not printing desired lengths

After you have uploaded Marlin you need to calibrate a few things, X Y Z and Extruder stepper motors and making sure the bed is level.

To calibrate the stepper motors see the video below, this video is for the Extruder however the same theory applies to the other stepper motors.

https://www.youtube.com/watch?v=w_Wb0i0-Qvo&list=FLsBw9MazlOn_-0v7O8OSgwg&index=7

For X and Y find a reference point on the side of the x carriage or front of the Y frame take a measurement to the extruder module or the front of the bed. Then in Pronterface of Repetier host move the axis by 50mm and then see how far the extruder module or the bed actually moves. Next, find you current E-steps in marlin under the configuration.h file and make a note.

Then use this equation  (expected distance / actual distance) * current steps per mm = new steps.
so if I asked X to move 10mm and it only moved 7 I would do 10/2 = 5 then find my current steps per mm for the X axis and times it by 5.

This works for the Z axis as well.

Then enter the new E-steps into Marlin, upload and save. You can also alter the E-steps on a lcd and save to eprom if you have this enabled. On the LCD go to Control => Motion and scroll down to Xsteps, Ysteps, Zsteps and Esteps. Click on then and change the value accordingly. Then go back to the control menu and click save. This saves the steps for each axis.

Thursday, 17 July 2014

Slic3r, pronterface and Repetier host

So now you have uploaded Malin to your Arduino mega, you are now ready to control your printer and make slight adjustments to you printer through Marlin.

There are two options that I would suggest,

Pronterface or Repetier host, these programmes are used to control your printer from your computer, you upload G code files to your printer through these programmes. Both are simple to use and there is well documented help on line as to how to set them up correctly, basically setting com port and baud rate and you good to go.

Before you print you need a design or file to print, you can download quite a few things on Thingiverse or you design your own products on free CAD software called Google sketch up and install the STL plugin which converts your design to a .STL file.

Once you have downloaded your STL file or created it you need to slice it into G-code. This creates your file as layers of X and Y movements to print the layers. To do this I would recommend Slic3r. Once you have slicer you need to go through all the settings and make sure these settings are correct for you printer. There is a great video below, this video goes through all the settings in Slic3r.


Thursday, 10 July 2014

How to setup an arduino Mega and upload Marlin

So I have been using Arduino's for quite a while before I got my 3D printer, when I saw the listing for this printer (as I got it on Ebay) I was thrilled to find out that it used an Arduino Mega. I thought great I might be able to add things into Marlin, I was wrong, the Marlin "sketch" was a lot more complicated than I thought (I didn't even know you could create tabs at the top of the page!).

Before my printer had arrived I had a look at the code and started to configure it for my printer that I had just bought. Setting up Marlin without any additional features is fairly straight forward as the sketch is very well commented so I managed to do it in about 10 minutes or so.

However if you aren't familiar with the Arduino language or how to set it up in the first place it can be quite frustrating.

The first thing you want to do is install the Arduino IDE, you can download it here: http://arduino.cc/en/Main/Software

Next you will need to install the driver for the Arduino Mega, the guide below is for an Arduino Uno but the process is very similar if not the same. 

Here is the guide: http://arduino.cc/en/guide/windows

Once you have installed both of these you can go ahead and download Marlin here: https://github.com/ErikZalm/Marlin



The Marlin firmware is down loaded as a .ZIP file so you will need to extract it, to do this, open the .ZIP file and at the top you will see a tab saying "Extract". Then click "extract all" and choose or create a folder for the files to be extracted to.

Once extracted you can now open the Arduino sketch, to do this, open up the Arduino IDE, go to File -> Open -> Marlin folder then select the Marlin.pde file.


This will then open the marlin sketch in the Arduino IDE so you can upload this to the Arduino mega board. To upload click the arrow button, right of the tick button.


However make sure you settings are correct in the configuration.h file before you try to print as it is very important to make sure the correct thermistor is being used to prevent overheating and stop a possible fire hazard. To open configuration.h file, open marlin in the Arduino IDE and you should see tabs across the top of the page. One of these will be the configuration.h file.

Also before you upload make sure the correct board is selected by going to tools => board and select the Arduino mega 2560. Also make sure the correct port is being used by going to tools => serial port and select one of the com ports.

Once this is done you can go ahead and open up and software that you prefer to use to control your 3D printer. I will be going over one of the most common programme used to control 3D printers in my next post.

Thursday, 19 June 2014

Arduino with a thermistor, LDR and RGB LED which changes colour based on temperature - prints data to PLX-DAQ Excel spreedsheet

Code gets:

- Temperature from a thermistor

- Light value from an LDR

and

RGB LED changes colour depending on the Temperature

Prints the data to the Serial Monitor

Data is sent to an Excel spreadsheet through data acquisition software, PLX-DAQ, Download here

Please let me know if you experience any problems with this code. Be sure to check back for more Arduino code.

Schematic:


 Code:

 /*  
   
 Oliver Holden  
 Created 28/10/2014  
   
 Components:  
 * Arduino UNO  
 * Thermistor  
 * 10K resistor  
 * LDR  
 * 10K resistor  
 * RGB LED  
 * 3x 220 ohm resistors  
   
 - Gets Temperature form a Thermistor  
   
 - Gets an analogue value of Light from an LDR  
   
 - RGB LED changes colour depending on the Temperature   
   
 Prints the data to the Serial Monitor  
 Data is sent to an Excel spreadsheet through data   
 acquisition software, PLX-DAQ, Download http://www.parallax.com/downloads/plx-daq  
   
 Schematic for this project is on  
 http://electrical-teen.blogspot.co.uk/  
   
 */  
   
   
 int redPin = 11;  // Red LED,  connected to digital pin 11  
 int grnPin = 10; // Green LED, connected to digital pin 10  
 int bluPin = 9; // Blue LED, connected to digital pin 9  
   
 int ThermistorPin = A0;  // Thermistor Reading pin  
 int LDRPin= A2;   // LDR Reading pin  
   
 int LDRReading = analogRead(LDRPin);   // Reading LDR analogue value  
   
 int x = 0;   // For PLX-DAQ  
 int row = 0;   // For PLX-DAQ  
   
   
 void setup()  
 {  
   Serial.begin(9600);   // Opening serial connection at 9600bps  
  Serial.println("Thermistor temperature and LDR light measurement:");   // Printing Serial Monitor header  
  Serial.println("LABEL, Time, T (C), LDR");   // Setting headers of colums in PLX-DAQ spreadsheet  
  Serial.println("\n-----------------------------");  
   
  pinMode(redPin, OUTPUT);  // sets the LED pins as output  
  pinMode(grnPin, OUTPUT);  
  pinMode(bluPin, OUTPUT);  
    
          
 }  
   
 void loop() {  
    
 int Vo;   // Integer value of voltage reading  
   
 float R = 9870.0;   // Fixed resistance in the voltage divider  
 float logRt,Rt,T;  
 float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;  
   
 Vo = analogRead(ThermistorPin);   // Reading voltage Thermistor Reading pin  
   
 Rt = R*( 1023.0 / (float)Vo - 1.0 );  
   
 logRt = log(Rt);  
   
 T = ( 1.0 / (c1 + c2*logRt + c3*logRt*logRt*logRt ) ) - 273.15;   // Converting voltage to temperature  
   
 Serial.print("     "); Serial.print(T);  // Printing data to Serial Monitor  
   
   
 Serial.print("     "); Serial.print(LDRReading);  
   
   
 // Setting the colours of the RGB LED based on temperature,  
 // Colour is shown for 0.1s before checking temperature again.  
   
 if(T >= 26.2)  
  {  
   digitalWrite(redPin, HIGH);  // red  
   delay(100);  
     
   digitalWrite(grnPin, LOW);  
   digitalWrite(bluPin, LOW);  
   
  }  
   
 if((T < 26) && (T >= 23.2))  
  {  
   digitalWrite(redPin, HIGH);  // yellow  
   digitalWrite(grnPin, HIGH);  
   delay(100);  
     
   digitalWrite(bluPin, LOW);  
   
  }  
    
  if((T < 23) && (T > 20.2))  
  {  
   digitalWrite(grnPin, HIGH);  // green  
   delay(100);  
     
   digitalWrite(redPin, LOW);  
   digitalWrite(bluPin, LOW);  
    
  }  
   
 if((T < 20) && (T > 17.2))  
  {  
   digitalWrite(grnPin, HIGH);  // aqua  
   digitalWrite(bluPin, HIGH);  
   delay(100);  
     
   digitalWrite(redPin, LOW);  
     
   
  }  
   
  if(T <= 17)  
  {  
   digitalWrite(bluPin, HIGH);  // blue  
   delay(100);  
     
   digitalWrite(grnPin, LOW);  
   digitalWrite(redPin, LOW);  
    
  }           
    
  row++;   // For PLX-DAQ  
  x++;   // For PLX-DAQ  
    
  delay(1000);   // Printing data once a second  
   
 }  

Thursday, 12 June 2014

Arduino with a thermistor, LDR and RGB LED that changes colour with temperature

Code gets:

- Temperature from a thermistor

- Light value from an LDR

and

RGB LED changes colour depending on the Temperature

Prints the data to the Serial Monitor


Please let me know if you experience any problems with this code. Be sure to check back for more Arduino code.

Schematic:


Code:


 /*  
   
 Oliver Holden  
 Created 28/10/2014  
   
 Components:  
 * Arduino UNO  
 * Thermistor  
 * 10K resistor  
 * LDR  
 * 10K resistor  
 * RGB LED  
 * 3x 220 ohm resistors  
   
 - Gets Temperature form a Thermistor  
   
 - Gets an analogue value of Light from an LDR  
   
 - RGB LED changes colour depending on the Temperature   
   
 Prints the data to the Serial Monitor  
   
 Schematic for this project is on  
 http://electrical-teen.blogspot.co.uk/  
   
 */  
   
 int redPin = 11;  // Red LED,  connected to digital pin 11  
 int grnPin = 10; // Green LED, connected to digital pin 10  
 int bluPin = 9; // Blue LED, connected to digital pin 9  
   
 int ThermistorPin = A0;  // Thermistor Reading pin  
 int LDRPin= A2;   // LDR Reading pin  
   
 int LDRReading = analogRead(LDRPin);   // Reading LDR analogue value  
   
 void setup()  
 {  
   Serial.begin(9600);   // Opening serial connection at 9600bps  
  Serial.println("Thermistor temperature and LDR light measurement:");   // Printing Serial Monitor header  
  Serial.println(" T (C), LDR");   // Setting headers of colums in PLX-DAQ spreadsheet  
  Serial.println("\n-----------------------------");  
   
  pinMode(redPin, OUTPUT);  // sets the LED pins as output  
  pinMode(grnPin, OUTPUT);  
  pinMode(bluPin, OUTPUT);  
    
          
 }  
   
 void loop() {  
    
 int Vo;   // Integer value of voltage reading  
   
 float R = 9870.0;   // Fixed resistance in the voltage divider  
 float logRt,Rt,T;  
 float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;  
   
 Vo = analogRead(ThermistorPin);   // Reading voltage Thermistor Reading pin  
   
 Rt = R*( 1023.0 / (float)Vo - 1.0 );  
   
 logRt = log(Rt);  
   
 T = ( 1.0 / (c1 + c2*logRt + c3*logRt*logRt*logRt ) ) - 273.15;   // Converting voltage to temperature  
   
 Serial.print("     "); Serial.print(T);  // Printing data to Serial Monitor  
   
   
 Serial.print("     "); Serial.print(LDRReading);  
   
   
 // Setting the colours of the RGB LED based on temperature,  
 // Colour is shown for 0.1s before checking temperature again.  
   
 if(T >= 26.2)  
  {  
   digitalWrite(redPin, HIGH);  // red  
   delay(100);  
     
   digitalWrite(grnPin, LOW);  
   digitalWrite(bluPin, LOW);  
   
  }  
   
 if((T < 26) && (T >= 23.2))  
  {  
   digitalWrite(redPin, HIGH);  // yellow  
   digitalWrite(grnPin, HIGH);  
   delay(100);  
     
   digitalWrite(bluPin, LOW);  
   
  }  
    
  if((T < 23) && (T > 20.2))  
  {  
   digitalWrite(grnPin, HIGH);  // green  
   delay(100);  
     
   digitalWrite(redPin, LOW);  
   digitalWrite(bluPin, LOW);  
    
  }  
   
 if((T < 20) && (T > 17.2))  
  {  
   digitalWrite(grnPin, HIGH);  // aqua  
   digitalWrite(bluPin, HIGH);  
   delay(100);  
     
   digitalWrite(redPin, LOW);  
     
   
  }  
   
  if(T <= 17)  
  {  
   digitalWrite(bluPin, HIGH);  // blue  
   delay(100);  
     
   digitalWrite(grnPin, LOW);  
   digitalWrite(redPin, LOW);  
    
  }   
    
  delay(1000);   // Printing data once a second  
   
 }  

Thursday, 5 June 2014

Arduino with a thermistor and LDR to get temperature and light value - prints data to PLX-DAQ Excel spreadsheet

Code gets:

- Temperature from a thermistor

- Light value from an LDR

and

Prints the data to the Serial Monitor

Data is sent to an Excel spreadsheet through data acquisition software, PLX-DAQ, Download here


Please let me know if you experience any problems with this code. Be sure to check back for more Arduino code.

Schematic:




Code:


 /*  
   
 Oliver Holden  
 Created 28/10/2014  
   
 Components:  
 * Arduino UNO  
 * Thermistor  
 * 10K resistor  
 * LDR  
 * 10K resistor  
   
 - Gets Temperature form a Thermistor  
   
 - Gets an analogue value of Light from an LDR  
   
 Prints the data to the Serial Monitor  
 Data is sent to an Excel spreadsheet through data   
 acquisition software, PLX-DAQ, Download http://www.parallax.com/downloads/plx-daq  
   
 Schematic for this project is on  
 http://electrical-teen.blogspot.co.uk/  
   
 */  
   
 int ThermistorPin = A0;  // Thermistor Reading pin  
 int LDRPin= A2;   // LDR Reading pin  
   
 int LDRReading = analogRead(LDRPin);   // Reading LDR analogue value  
   
 int x = 0;   // For PLX-DAQ  
 int row = 0;   // For PLX-DAQ  
   
   
 void setup()  
 {  
   Serial.begin(9600);   // Opening serial connection at 9600bps  
  Serial.println("Thermistor temperature and LDR light measurement:");   // Printing Serial Monitor header  
  Serial.println("LABEL, Time, T (C), LDR");   // Setting headers of colums in PLX-DAQ spreadsheet  
  Serial.println("\n-----------------------------");  
          
 }  
   
 void loop() {  
    
 int Vo;   // Integer value of voltage reading  
   
 float R = 9870.0;   // Fixed resistance in the voltage divider  
 float logRt,Rt,T;  
 float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;  
   
 Vo = analogRead(ThermistorPin);   // Reading voltage Thermistor Reading pin  
   
 Rt = R*( 1023.0 / (float)Vo - 1.0 );  
   
 logRt = log(Rt);  
   
 T = ( 1.0 / (c1 + c2*logRt + c3*logRt*logRt*logRt ) ) - 273.15;   // Converting voltage to temperature  
   
 Serial.print("     "); Serial.print(T);  // Printing data to Serial Monitor  
   
   
 Serial.print("     "); Serial.print(LDRReading);  
   
  row++;   // For PLX-DAQ  
  x++;   // For PLX-DAQ  
    
  delay(1000);   // Printing data once a second  
   
 }  
   

Thursday, 29 May 2014

Arduino with a Thermistor and LDR to get temperature and light value

Code gets:

- Temperature from a thermistor

- Light value from an LDR

and

Prints the data to the Serial Monitor


Please let me know if you experience any problems with this code. Be sure to check back for more Arduino code.

Schematic:




Code:

 /*  
   
 Oliver Holden  
 Created 28/10/2014  
   
 Components:  
 * Arduino UNO  
 * Thermistor  
 * 10K resistor  
 * LDR  
 * 10K resistor  
   
 - Gets Temperature form a Thermistor  
   
 - Gets an analogue value of Light from an LDR  
   
 Prints the data to the Serial Monitor  
   
 Schematic for this project is on  
 http://electrical-teen.blogspot.co.uk/  
   
 */  
   
 int ThermistorPin = A0;  // Thermistor Reading pin  
 int LDRPin= A2;   // LDR Reading pin  
   
 int LDRReading = analogRead(LDRPin);   // Reading LDR analogue value  
   
 void setup()  
 {  
   Serial.begin(9600);   // Opening serial connection at 9600bps  
  Serial.println("Thermistor temperature and LDR light measurement:");   // Printing Serial Monitor header  
  Serial.println(" T (C), LDR");   // Setting headers of colums in PLX-DAQ spreadsheet  
  Serial.println("\n-----------------------------");   
          
 }  
   
 void loop() {  
    
 int Vo;   // Integer value of voltage reading  
   
 float R = 9870.0;   // Fixed resistance in the voltage divider  
 float logRt,Rt,T;  
 float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;  
   
 Vo = analogRead(ThermistorPin);   // Reading voltage Thermistor Reading pin  
   
 Rt = R*( 1023.0 / (float)Vo - 1.0 );  
   
 logRt = log(Rt);  
   
 T = ( 1.0 / (c1 + c2*logRt + c3*logRt*logRt*logRt ) ) - 273.15;   // Converting voltage to temperature  
   
 Serial.print("     "); Serial.print(T);  // Printing data to Serial Monitor  
   
   
 Serial.print("     "); Serial.print(LDRReading);  
   
   
  delay(1000);   // Printing data once a second  
   
 }  
   

Thursday, 22 May 2014

Arduino with a thermistor and RGB LED - PLX-DAQ Excel spreadsheet

Code gets:

- Temperature from a thermistor

and

RGB LED changes colour depending on the Temperature

Prints the data to the Serial Monitor

Data is sent to an Excel spreadsheet through data acquisition software, PLX-DAQ, Download here

Please let me know if you experience any problems with this code. Be sure to check back for more Arduino code.

Schematic:



Code:


 /*  
   
 Oliver Holden  
 Created 28/10/2014  
   
 Components:  
 * Arduino UNO  
 * Thermistor  
 * 10K resistor  
 * RGB LED  
 * 3x 220 ohm resistors  
   
 - Gets Temperature form a Thermistor  
   
 - RGB LED changes colour depending on the Temperature   
   
 Prints the data to the Serial Monitor  
   
 Data is sent to an Excel spreadsheet through data   
 acquisition software, PLX-DAQ, Download http://www.parallax.com/downloads/plx-daq  
   
 Schematic for this project is on  
 http://electrical-teen.blogspot.co.uk/  
   
 */  
   
 int redPin = 11;  // Red Leg of LED,  connected to digital pin 11  
 int grnPin = 10; // Green Leg of LED, connected to digital pin 10  
 int bluPin = 9; // Blue Leg of LED, connected to digital pin 9  
   
 int ThermistorPin = A0;  // Thermistor Reading pin  
   
 void setup()  
 {  
  Serial.begin(9600);   // Opening serial connection at 9600bps  
  Serial.println("Thermistor temperature measurement:");   // Printing Serial Monitor header    
  Serial.println("\n      Vo      Rt      T (C)");             
    
  pinMode(redPin, OUTPUT);  // Sets the LED pins as outputs  
  pinMode(grnPin, OUTPUT);  
  pinMode(bluPin, OUTPUT);  
          
 }  
   
 void loop() {  
    
 int Vo;   // Integer value of voltage reading  
   
 float R = 9870.0; // Fixed resistance in the voltage divider  
 float logRt,Rt,T;  
 float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;  
   
 Vo = analogRead(ThermistorPin);  // Reading voltage of Thermistor Reading pin  
   
 Rt = R*( 1023.0 / (float)Vo - 1.0 );  
   
 logRt = log(Rt);  
   
 T = ( 1.0 / (c1 + c2*logRt + c3*logRt*logRt*logRt ) ) - 273.15;  // converting voltage to temperature  
   
   
 Serial.print("     "); Serial.print(Vo);  // Printing data to Serial Monitor  
   
   
 Serial.print("     "); Serial.print(Rt);  
   
   
 Serial.print("     "); Serial.println(T);  
   
   
 // Setting the colours of the RGB LED based on temperature,  
 // Colour is shown for 0.1s before checking temperature again.  
   
 if(T >= 26.2)  
  {  
   digitalWrite(redPin, HIGH);  // red  
   delay(100);  
     
   digitalWrite(grnPin, LOW);  
   digitalWrite(bluPin, LOW);  
   
  }  
   
 if((T < 26) && (T >= 23.2))  
  {  
   digitalWrite(redPin, HIGH);  // yellow  
   digitalWrite(grnPin, HIGH);  
   delay(100);  
     
   digitalWrite(bluPin, LOW);  
   
  }  
    
  if((T < 23) && (T > 20.2))  
  {  
   digitalWrite(grnPin, HIGH);  // green  
   delay(100);  
     
   digitalWrite(redPin, LOW);  
   digitalWrite(bluPin, LOW);  
    
  }  
   
 if((T < 20) && (T > 17.2))  
  {  
   digitalWrite(grnPin, HIGH);  // aqua  
   digitalWrite(bluPin, HIGH);  
   delay(100);  
     
   digitalWrite(redPin, LOW);  
     
   
  }  
   
  if(T <= 17)  
  {  
   digitalWrite(bluPin, HIGH);  // blue  
   delay(100);  
     
   digitalWrite(grnPin, LOW);  
   digitalWrite(redPin, LOW);  
    
  }  
 }  

Thursday, 15 May 2014

Arduino with a thermistor and RGB LED

Code gets:

- Temperature from a thermistor

and

 RGB LED changes colour depending on the Temperature

Prints the data to the Serial Monitor


Please let me know if you experience any problems with this code. Be sure to check back for more Arduino code.

Schematic:


Code:


 /*  
   
 Oliver Holden  
 Created 28/10/2014  
   
 Components:  
 * Arduino UNO  
 * Thermistor  
 * 10K resistor  
 * RGB LED  
 * 3x 220 ohm resistors  
   
 - Gets Temperature form a Thermistor  
 - RGB LED changes colour depending on the Temperature   
   
 Prints the data to the Serial Monitor  
   
 Schematic for this project is on  
 http://electrical-teen.blogspot.co.uk/  
   
 */  
   
 int redPin = 11;  // Red Leg of LED,  connected to digital pin 11  
 int grnPin = 10; // Green Leg of LED, connected to digital pin 10  
 int bluPin = 9; // Blue Leg of LED, connected to digital pin 9  
   
 int ThermistorPin = A0;  // Thermistor Reading pin  
   
 void setup()  
 {  
  Serial.begin(9600);   // Opening serial connection at 9600bps  
  Serial.println("Thermistor temperature measurement:");   // Printing Serial Monitor header    
  Serial.println("\n      Vo      Rt      T (C)");             
    
  pinMode(redPin, OUTPUT);  // Sets the LED pins as outputs  
  pinMode(grnPin, OUTPUT);  
  pinMode(bluPin, OUTPUT);  
          
 }  
   
 void loop() {  
    
 int Vo;   // Integer value of voltage reading  
   
 float R = 9870.0; // Fixed resistance in the voltage divider  
 float logRt,Rt,T;  
 float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;  
   
 Vo = analogRead(ThermistorPin);  // Reading voltage of Thermistor Reading pin  
   
 Rt = R*( 1023.0 / (float)Vo - 1.0 );  
   
 logRt = log(Rt);  
   
 T = ( 1.0 / (c1 + c2*logRt + c3*logRt*logRt*logRt ) ) - 273.15;  // converting voltage to temperature  
   
   
 Serial.print("     "); Serial.print(Vo);  // Printing data to Serial Monitor  
   
   
 Serial.print("     "); Serial.print(Rt);  
   
   
 Serial.print("     "); Serial.println(T);  
   
   
 // Setting the colours of the RGB LED based on temperature,  
 // Colour is shown for 0.1s before checking temperature again.  
   
 if(T >= 26.2)  
  {  
   digitalWrite(redPin, HIGH);  // red  
   delay(100);  
     
   digitalWrite(grnPin, LOW);  
   digitalWrite(bluPin, LOW);  
   
  }  
   
 if((T < 26) && (T >= 23.2))  
  {  
   digitalWrite(redPin, HIGH);  // yellow  
   digitalWrite(grnPin, HIGH);  
   delay(100);  
     
   digitalWrite(bluPin, LOW);  
   
  }  
    
  if((T < 23) && (T > 20.2))  
  {  
   digitalWrite(grnPin, HIGH);  // green  
   delay(100);  
     
   digitalWrite(redPin, LOW);  
   digitalWrite(bluPin, LOW);  
    
  }  
   
 if((T < 20) && (T > 17.2))  
  {  
   digitalWrite(grnPin, HIGH);  // aqua  
   digitalWrite(bluPin, HIGH);  
   delay(100);  
     
   digitalWrite(redPin, LOW);  
     
   
  }  
   
  if(T <= 17)  
  {  
   digitalWrite(bluPin, HIGH);  // blue  
   delay(100);  
     
   digitalWrite(grnPin, LOW);  
   digitalWrite(redPin, LOW);  
    
  }  
 }  

Thursday, 8 May 2014

RGB LED that changes colour every 0.1s - you can set the colours, order and duration

Basic code to create a flashing RGB LED that changes colour.
Please let me know if you experience any problems with this code. Be sure to check back for more Arduino code.

Schematic:


Code:


 /*  
   
 Oliver Holden  
 Created 28/10/2014  
   
 Components:  
 * Arduino UNO  
 * RGB LED  
 * 3x 220 ohm resistors  
   
 - RGB changes colour every 0.1s  
   
 Schematic for this project is on  
 http://electrical-teen.blogspot.co.uk/  
   
 */  
   
 int redPin = 11;   // Red LED,  connected to digital pin 11  
 int grnPin = 10;   // Green LED, connected to digital pin 10  
 int bluPin = 9;   // Blue LED, connected to digital pin 9  
   
    
 void setup()  
 {  
  pinMode(redPin, OUTPUT);   // Setting LED pins as outputs  
  pinMode(grnPin, OUTPUT);  
  pinMode(bluPin, OUTPUT);   
 }  
    
 void loop()  
 {  
  setColor(255, 0, 0); // red   // Going through different colours  
  delay(100);           // Each colour is on for 100ms  
  setColor(0, 255, 0); // green  
  delay(100);  
  setColor(0, 0, 255); // blue  
  delay(100);  
  setColor(255, 255, 0); // yellow  
  delay(100);   
  setColor(80, 0, 80); // purple  
  delay(100);  
  setColor(0, 255, 255); // aqua  
  delay(100);  
 }  
    
 void setColor(int red, int green, int blue)   // Setting colours  
 {  
  analogWrite(redPin, red);  
  analogWrite(grnPin, green);  
  analogWrite(bluPin, blue);   
 }  

Thursday, 1 May 2014

Arduino with RGB LED to create any colour you want

Basic code to create an LED of any colour from an RGB LED.
Please let me know if you experience any problems with this code. Be sure to check back for more Arduino code.

Schematic:


Code:

 /*  
   
 Oliver Holden  
 Created 28/10/2014  
   
 Components:  
 * Arduino UNO  
 * RGB LED  
 * 3x 220 ohm resistors  
   
 - Create an LED that can dispaly any colour you want  
   
 Schematic for this project is on  
 http://electrical-teen.blogspot.co.uk/  
   
 */  
   
 int redPin = 11;   // Red LED,  connected to digital pin 11  
 int grnPin = 10;   // Green LED, connected to digital pin 10  
 int bluPin = 9;   // Blue LED, connected to digital pin 9  
   
    
 void setup()  
 {  
  pinMode(redPin, OUTPUT);   // Setting LED pins as outputs  
  pinMode(grnPin, OUTPUT);  
  pinMode(bluPin, OUTPUT);   
 }  
    
 void loop()  
 {  
  setColor(255, 255, 255); // (R,G,B) - change the numbers to a value between 0 and 255  
 }  
    
 void setColor(int red, int green, int blue)   // Setting colours  
 {  
  analogWrite(redPin, red);  
  analogWrite(grnPin, green);  
  analogWrite(bluPin, blue);   
 }  
   

Thursday, 24 April 2014

Arduino with a LDR - PLX-DAQ Excel spreadsheet

Arduino circuit with an LDR to get an analogue value of light, prints data to Serial Monitor                                                  and PLX-DAQ Excel spreadsheet. 
Please let me know if you experience any problems with this code. Be sure to check back for more Arduino code.

                                                                   Schematic:



                                                                         Code:


 /*  
   
 Oliver Holden  
 Created 28/10/2014  
   
 Components:  
 * Arduino UNO  
 * LDR  
 * 10K resistor  
   
 - Gets an analogue value of Light from an LDR  
   
 Prints the data to the Serial Monitor  
   
 Data is sent to an Excel spreadsheet through data   
 acquisition software, PLX-DAQ, Download http://www.parallax.com/downloads/plx-daq  
   
 Schematic for this project is on  
 http://electrical-teen.blogspot.co.uk/  
   
 */  
   
 int LDRPin= A2;   // LDR Reading Pin  
   
 int LDRReading = analogRead(LDRPin);   // Reading analogue value from LDR  
   
 int x = 0;   // For PLX-DAQ  
 int row = 0;   // For PLX-DAQ  
     
 void setup()  
 {  
   Serial.begin(9600);   // Opening serial connection at 9600bps    
  Serial.println("Light");   //Printing Serial Monitor header  
  Serial.println("LABEL, Time, LDR");   // Setting headers of colums in PLX-DAQ spreadsheet     
  Serial.println("\n-----------------");  
   
 }  
   
 void loop() {  
   
 Serial.println(LDRReading);   // Printing data to Serial Monitor   
   
 row++;   // For PLX-DAQ  
 x++;   // For PLX-DAQ  
   
 delay(1000);   // Printing data once a second  
 }  
   

Thursday, 17 April 2014

Arduino with a LDR

Arduino circuit with an LDR to get an analogue value of light, prints data to Serial Monitor. 
Please let me know if you experience any problems with this code. Be sure to check back for more Arduino code.

Schematic:


Code:

 /*  
   
 Oliver Holden  
 Created 28/10/2014  
   
 Components:  
 * Arduino UNO  
 * LDR  
 * 10K resistor  
   
 - Gets an analogue value of Light from an LDR  
   
 Prints the data to the Serial Monitor  
   
 Schematic for this project is on  
 http://electrical-teen.blogspot.co.uk/  
   
 */  
   
   
 int LDRPin= A2;   // LDR Reading Pin  
   
 int LDRReading = analogRead(LDRPin);   // Reading analogue value from LDR  
     
 void setup()  
 {  
   Serial.begin(9600);   // Opening serial connection at 9600bps    
  Serial.println("Light");   //Printing Serial Monitor header  
  Serial.println("\n-----------------");  
   
 }  
   
 void loop() {  
   
 Serial.println(LDRReading);   // Printing data to Serial Monitor   
   
 delay(1000);   // Printing data once a second  
 }  
   

Arduino with a thermistor to get temperature - PLX-DAQ Excel spreadsheet


Simple Arduino circuit to get temperature from a thermistor, prints data to Serial Monitor and PLX-DAQ Excel spreadsheet.
Please let me know if you experience any problems with this code. Be sure to check back for more Arduino code.

Schematic:


Code:

 /*  
   
 Oliver Holden  
 Created 28/10/2014  
   
 Components:  
 * Arduino UNO  
 * Thermistor  
 * 10K resistor  
   
 - Gets Temperature form a Thermistor  
   
 Prints the data to the Serial Monitor  
   
 Data is sent to an Excel spreadsheet through data   
 acquisition software, PLX-DAQ, Download http://www.parallax.com/downloads/plx-daq  
   
 Schematic for this project is on  
 http://electrical-teen.blogspot.co.uk/  
   
 */  
   
   
 int ThermistorPin = A0;   // Thermister Reading pin  
   
 int x = 0;   // For PLX-DAQ  
 int row = 0;   // For PLX-DAQ  
   
 void setup()   
 {  
 Serial.begin(9600);   // Opening serial connection at 9600bps  
 Serial.println("Thermistor temperature measurement:");   // Printing Serial Monitor header  
 Serial.println("LABEL, Time, Vo, Rt, T (C)");   // Setting headers of colums in PLX-DAQ spreadsheet  
 Serial.println("\n      Vo      Rt      T (C)");  
 }  
   
 void loop() {  
    
 int Vo;   
   
 float R = 9870.0;   // Fixed resistance in the voltage divider   
 float logRt,Rt,T;  
 float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;  
   
 Vo = analogRead(ThermistorPin);   // Reading voltage of Thermistor Reading pin  
   
 Rt = R*( 1023.0 / (float)Vo - 1.0 );  
   
 logRt = log(Rt);  
   
 T = ( 1.0 / (c1 + c2*logRt + c3*logRt*logRt*logRt ) ) - 273.15;   // Convertion to get temperature from thermistor  
   
 Serial.print("     "); Serial.print(Vo);   // Printing data to Serial Monitor  
   
   
 Serial.print("     "); Serial.print(Rt);  
   
   
 Serial.print("     "); Serial.println(T);  
   
 row++;   // For PLX-DAQ  
 x++;   // For PLX-DAQ  
   
 delay(1000);   // Printing data once per second  
 }  

Thursday, 10 April 2014

Arduino with a thermistor to get temperature


Simple Arduino circuit to get temperature from a simple thermistor, prints data to Serial Monitor. 
Please let me know if you experience any problems with this code. Be sure to check back for more Arduino code.

Schematic:



Code:


 /*  
   
 Oliver Holden  
 Created 28/10/2014  
   
 Components:  
 * Arduino UNO  
 * Thermistor  
 * 10K resistor  
   
 - Gets Temperature form a Thermistor  
   
 Prints the data to the Serial Monitor  
   
 Schematic for this project is on  
 http://teenengineer.blogspot.co.uk/  
   
 */  
   
   
 int ThermistorPin = A0;   // Thermister Reading pin  
   
 void setup()   
 {  
 Serial.begin(9600);   // Opening serial connection at 9600bps  
 Serial.println("Thermistor temperature measurement:");   // Printing Serial Monitor header  
 Serial.println("\n      Vo      Rt      T (C)");  
 }  
   
 void loop() {  
    
 int Vo;   // Integer value of voltage reading  
   
 float R = 9870.0;   // Fixed resistance in the voltage divider  
 float logRt,Rt,T;  
 float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;  
   
 Vo = analogRead(ThermistorPin);   // Reading voltage of Thermistor Reading pin      
   
 Rt = R*( 1023.0 / (float)Vo - 1.0 );  
   
 logRt = log(Rt);  
   
 T = ( 1.0 / (c1 + c2*logRt + c3*logRt*logRt*logRt ) ) - 273.15;   // Convertion to get temperature from thermistor  
   
 Serial.print("     "); Serial.print(Vo);   // Printing data to Serial Monitor  
   
   
 Serial.print("     "); Serial.print(Rt);  
   
   
 Serial.print("     "); Serial.println(T);  
   
 delay(1000);   // Printing data once per second  
 }  
   

Contact Form

Name

Email *

Message *