Sunday, December 15, 2013

Contribution:
The whole team worked as one person; we all had one goal which was to achieve and design a mechanism, so we can say that everyone in the group worked as much hard everyone else in the group. 

On the presentation day, 

Here is another code for servo, LEDS, LCD, temperature sensor, dc motor


#include <Servo.h>
Servo myservo;
int tempIn = 0;       // temperature sensor on Analogue Pin 3
int ledOut = 8;       // LED on Digital Pin 8
int LedOut1 = 10;      // LED on Digital Pin 10
int aiValue = 0;       // input value (0-1023 = 0 to 5v)
float setPoint = 30;    // Trigger value in 'C
float deadband = 0.5; // Differential for reset value in 'C
int potpin = 0;
int val;
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
const int buttonPin =  1;
const int MotorPin = 7;
int x=0;
/*
  NOTE: the deadband action can be disabled by setting the deadband to 0
 */
float degC;            // The temperature in Degrees Centigrade
void setup(){
  {
    pinMode(ledOut, OUTPUT);  // Configure the Digital Pin Direction for the LED
    pinMode(LedOut1, OUTPUT);
    lcd.begin(16, 2);
    lcd.clear();
    Serial.begin(9600);
  }
  {
    myservo.attach(9); // attaches the servo on pin 9 to the servo object
  }
  {
    pinMode(buttonPin, INPUT);
    pinMode(MotorPin, OUTPUT);
  }
}
void loop()
{

  degC = getTemperature(getVolts());      //Get the Volts and the Temperature using Helper functions.

  if (degC > setPoint)
  {
    digitalWrite(ledOut, HIGH);      // Temperature Limit Reached, turn the LED on.
    Serial.println(" | Output: ON.");
    lcd.setCursor(0,1);
    lcd.print("  Yellow  ");
    lcd.print(degC);


  }
  else
  {
    if (degC > (setPoint - deadband))
    {
      digitalWrite(ledOut, LOW);       // Temperature dropped below SP and deadband, turn the LED off.
      Serial.println(" | Output: OFF.");
      lcd.print("      ");
    }
  }
  if (degC < setPoint)
  {
    digitalWrite(LedOut1, HIGH);      // Temperature Limit Reached, turn the LED on.
    Serial.println(" | Output: ON.");
    lcd.setCursor(0,1);
    lcd.print("  RED   ");
    lcd.print(degC);
  }
  else
  {
    if (degC < (setPoint - deadband))
    {
      digitalWrite(LedOut1, LOW);       // Temperature dropped below SP and deadband, turn the LED off.
      Serial.println(" | Output: OFF.");
      lcd.print("      ");
    }
  }

  delay(1000);

  {
    val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
    val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
    myservo.write(val); // sets the servo position according to the scaled value
    delay(15); // waits for the servo to get there
  }
  {
    x=digitalRead(buttonPin);
    if(x==HIGH){
      digitalWrite(MotorPin,LOW);
    }
    else{
      digitalWrite(MotorPin,HIGH);
    }
  }
}
/*
Return the voltage for the input value; 0-1023 = 0 to 5V
 */
float getVolts()
{
  int inputValue;
  inputValue = analogRead(tempIn);
  float volts;
  volts = (((float)inputValue / 1024) * 5);

  Serial.print("Input Value: ") ;
  Serial.print(inputValue);
  Serial.print(" | Voltage: ") ;
  Serial.print(volts);
  return volts;
}
/*
Return the temperature in DegreesC for given voltage
 */
float getTemperature(float volts)
{
  float temp = (volts - 0.5) / 0.01 ;

  Serial.print(" | Temperature: ");
  Serial.print(temp);
  Serial.print(" 'C");

  return temp;
}

Wednesday, December 4, 2013


The DC motor drives the fan on the boat, and the servo drives the rudder. We plan on using a potentiometer to control the servo, and a push button to control the DC motor.
The team is meeting now, on Nov. 22, 2013. We are all working on building a boat. The solidworks of the boat is almost completed and we are working on various codes for the dc motor, servo, and LCD screen with the LED lights.

We are designing a boat that can be controlled by a DC motor, and a servo. We are also including a red LED to indicate that temperature is below some certain temperature (a temperature that we can set). We are also including a yellow LED to show that the temperature is now above the set temperature. Both action ( red or yellow) are going to be shown on a LCD with the current temperature at that moment.
hardware: 
1. temperature sensor.
2. LCD (16x2)
3. a red LED.
4. a yellow LED
5. potentiometer
6.  2 resistor.
 7. wires.
code:    
/*
Basic Analogue Input Control - Temperature Sensor
This example reads an analogue value from analogue in pin 1 and then compares this to a set point.
If the set point is threshold is crossed, the LED on digital pins 8,9 is turned on/off. A deadband is
provided to prevent high speed toggling at the set point transition.
The logic used below with act on Rising temperature.
The analogue input will come from a TMP36 temperature sensor.
-40'C to 125'C = 100mV to 1750mv (linear 10mV per 'C)
*/
int tempIn = 0;       // temperature sensor on Analogue Pin 3
int ledOut = 8;       // LED on Digital Pin 8
int LedOut1 = 9;      // LED on Digital Pin 9
int aiValue = 0;       // input value (0-1023 = 0 to 5v)
float setPoint =30;    // Trigger value in 'C
float deadband = 0.5;   // Differential for reset value in 'C
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
/*
  NOTE: the deadband action can be disabled by setting the deadband to 0
*/
float degC;            // The temperature in Degrees Centigrade
void setup()
{
  pinMode(ledOut, OUTPUT);  // Configure the Digital Pin Direction for the LED
  pinMode(LedOut1, OUTPUT);
  lcd.begin(16, 2);
  lcd.clear();
  Serial.begin(9600);
}
void loop()
{

  degC = getTemperature(getVolts());      //Get the Volts and the Temperature using Helper functions.
   
  if (degC > setPoint)
  {
    digitalWrite(ledOut, HIGH);      // Temperature Limit Reached, turn the LED on.
    Serial.println(" | Output: ON.");
     lcd.setCursor(0,1);
     lcd.print("  Yellow  ");
     lcd.print(degC);
   
   }
    else
  {
      if (degC > (setPoint - deadband))
      {
      digitalWrite(ledOut, LOW);       // Temperature dropped below SP and deadband, turn the LED off.
      Serial.println(" | Output: OFF.");
      lcd.setCursor(0,1);
      lcd.print("      ");
      }
  }
   if (degC < setPoint)
  {
    digitalWrite(LedOut1, HIGH);      // Temperature Limit Reached, turn the LED on.
    Serial.println(" | Output: ON.");
    lcd.setCursor(0,1);
    lcd.print("  RED   ");
    lcd.print(degC);
   }
    else
  {
      if (degC < (setPoint - deadband))
      {
      digitalWrite(LedOut1, LOW);       // Temperature dropped below SP and deadband, turn the LED off.
      Serial.println(" | Output: OFF.");
      lcd.setCursor(0,1);
      lcd.print("      ");
      }
  }
  
  delay(1000);
}
/*
Return the voltage for the input value; 0-1023 = 0 to 5V
*/
float getVolts()
{
  int inputValue;
  inputValue = analogRead(tempIn);
  float volts;
  volts = (((float)inputValue / 1024) * 5);
 
  Serial.print("Input Value: ") ; Serial.print(inputValue);
  Serial.print(" | Voltage: ") ; Serial.print(volts);
  return volts;
}
/*
Return the temperature in DegreesC for given voltage
*/
float getTemperature(float volts)
{
  float temp = (volts - 0.5) / 0.01 ;
 
  Serial.print(" | Temperature: "); Serial.print(temp); Serial.print(" 'C");
 
  return temp;
}
some images: