element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Serial won't work!
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 14 replies
  • Subscribers 402 subscribers
  • Views 1198 views
  • Users 0 members are here
  • help
  • work
  • heating
  • code
  • please
  • serial
  • won't
  • arduino
Related

Serial won't work!

Former Member
Former Member over 11 years ago

I'v bin trying to making a heating auto heating system that turns the knob with a servo, I can change the var upload and it will change position but every time i try to set up commands thought serial I get nothing, not even printing the serial I just sent.  I'v tried this over and over again in different variations and am starting to get sick of just having my arduino uno just hanging from my wall doing nothing. please help.

 

 

my code:

 

#include <Servo.h>

Servo officeHeat;

int heat40 = 800;

int heat45 = 950;

int heat50 = 1150;

int heat55 = 1325;

int heat60 = 1500;

int heat65 = 1700;

int heat70 = 1825;

int heat75 = 1975;

int heat80 = 2150;

int officeHeatSetTo = heat60;

 

void setup(){

  Serial.begin(9600);

  officeHeat.attach(9);

}

 

 

void loop(){

//check if serial is available

  while(Serial.available() > 0){

    //read serial and set var

    int heatCommand = Serial.read();

    //if the command is A then set heat to 65

    if(heatCommand == 'A'){

      officeHeatSetTo = heat65;

    }

}

  officeHeat.writeMicroseconds(officeHeatSetTo);

//tell computer the current set temp.

  while(true){

    if(officeHeatSetTo == 800){

    Serial.println("40");

  }

    if(officeHeatSetTo == 950){

    Serial.println("45");

  }

    if(officeHeatSetTo == 1150){

    Serial.println("50");

  }

    if(officeHeatSetTo == 1325){

    Serial.println("55");

  }

    if(officeHeatSetTo == 1500){

    Serial.println("60");

  }

      if(officeHeatSetTo == 1700){

    Serial.println("65");

  }

      if(officeHeatSetTo == 1825){

    Serial.println("70");

  }

      if(officeHeatSetTo == 1975){

    Serial.println("75");

  }

      if(officeHeatSetTo == 2150){

    Serial.println("80");

  }

  delay(1000);

}

}

  • Sign in to reply
  • Cancel
Parents
  • Robert Peter Oakes
    0 Robert Peter Oakes over 11 years ago

    I did notice that the Servo library does odd things at the low end of the range though, asking for lower pulse width actually ended up increasing the pulse width not decreasing it, i even added the initialization to try to mitigate it but it had no effect. I was monitoring with an oscilloscope to observe the output as I did not have an actual servo to hand

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to Robert Peter Oakes

    I got the numbers by trial and error so they should land on the right heat

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Robert Peter Oakes
    0 Robert Peter Oakes over 11 years ago in reply to Former Member

    what I mean by weird is the lowest numbers where not resulting in the smallest angle, probably something to do with the MAP function the library uses. If you use the angle version of the function is is OK (0 - 180)

     

    I will be posting my own set of tutorials for the Arduino soon including using the servo library and other features of programming (Serial Parsing, Ethernet Parsing etc etc) so stay tuned)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to Robert Peter Oakes

    I think your referring to me not using the full 180 degrees, this is because it has problems turning far with how i mounted it.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • Former Member
    0 Former Member over 11 years ago in reply to Robert Peter Oakes

    I think your referring to me not using the full 180 degrees, this is because it has problems turning far with how i mounted it.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • Robert Peter Oakes
    0 Robert Peter Oakes over 11 years ago in reply to Former Member

    Nope, thats ok, what I am saying is while I was testing, when slowly increasing the temp setting, I notice the pulse would increase from one temp to the next but then decrease from that to the next higher, then go back again on the next change. This was observed on a scope as well as on an actual servo

     

    once I adjusted the min - max range settings it all seemed to be ok but original settings it misbehaved in strange ways and this had nothing to do with the actual servo being used

     

    once I get to make the servo lesson video I will try to re-produce it, until then if it is all working for you, that's good.

     

    Peter

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube