element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • 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 Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • 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
Ben Heck Featured Content
  • Challenges & Projects
  • element14 presents
  • element14's The Ben Heck Show
  • Ben Heck Featured Content
  • More
  • Cancel
Ben Heck Featured Content
Documents Watch Ben Heck Build a Remote Expedition Camera! -- Episode 20
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Ben Heck Featured Content to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Engagement
  • Author Author: joeman
  • Date Created: 8 Jul 2011 2:22 PM Date Created
  • Last Updated Last Updated: 3 Jun 2011 7:24 AM
  • Views 1142 views
  • Likes 2 likes
  • Comments 3 comments
Related
Recommended

Watch Ben Heck Build a Remote Expedition Camera! -- Episode 20

image

element14's The Ben Heck Show

Join the Ben Heck team every week for amazing hacks! Watch them build and mod community-inspired projects using electronics!

Back to The Ben Heck Show homepage image

Connect with TBHS
Featured Bonus Materials
See All Episodes

 

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image
Phil Golden is embarking on Expedition Awareness, and Ben helps out with a remote control camera system with monitors nestled inside the car.
  • hack
  • hardware
  • mods
  • build
  • episode
  • build_challenge
  • idea
  • camera
  • challenge
  • expedition
  • ben_heck
  • heck
  • ben
  • remote
  • tbhs_ep
  • Share
  • History
  • More
  • Cancel
  • Sign in to reply
Parents
  • Former Member
    Former Member over 14 years ago

    Hey Ben,

    I liked this episode, but I had a suggestion to make your life easier. When you've got code that you want to remove easily from some builds (like serial debugs, or different peripheral options) of your firmware, use preprocessor defines.

     

    There's a couple ways to to this. The easiest would be to wrap each block where you're outputting serial data with an ifdef, eg.

     

    #ifdef SERIAL_DEBUG

      Serial.println("Hello World");

      Serial.print("Another Line, manually returned\r\n");

    #endif //SERIAL_DEBUG

     

    Then you can simple put the following line at the top of your file when you want to have the printing enabled.

    #define SERIAL_DEBUG

     

    Another more advanced technique would be to create a preprocessor function to do the printing, like follows. I don't use Arduino much, so I can't guarantee it will work, but it will in most C compilers

     

    #define SERIAL_DEBUG

    #ifdef SERIAL_DEBUG

      PRINT(X) Serial.print(X)

      PRINT(X,Y) Serial.print(X,Y)

      PRINTLN(X) Serial.println(X)

      WRITE(X) Serial.write(X)

    #else

      PRINT(X)

      PRINT(X,Y)

      PRINTLN(X)

      WRITE(X)

    #endif //SERIAL_DEBUG

     

    Then in your code, you can simply use those functions instead of the Serial functions, there's no need for any other diff files.

     

    David

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • Former Member
    Former Member over 14 years ago

    Hey Ben,

    I liked this episode, but I had a suggestion to make your life easier. When you've got code that you want to remove easily from some builds (like serial debugs, or different peripheral options) of your firmware, use preprocessor defines.

     

    There's a couple ways to to this. The easiest would be to wrap each block where you're outputting serial data with an ifdef, eg.

     

    #ifdef SERIAL_DEBUG

      Serial.println("Hello World");

      Serial.print("Another Line, manually returned\r\n");

    #endif //SERIAL_DEBUG

     

    Then you can simple put the following line at the top of your file when you want to have the printing enabled.

    #define SERIAL_DEBUG

     

    Another more advanced technique would be to create a preprocessor function to do the printing, like follows. I don't use Arduino much, so I can't guarantee it will work, but it will in most C compilers

     

    #define SERIAL_DEBUG

    #ifdef SERIAL_DEBUG

      PRINT(X) Serial.print(X)

      PRINT(X,Y) Serial.print(X,Y)

      PRINTLN(X) Serial.println(X)

      WRITE(X) Serial.write(X)

    #else

      PRINT(X)

      PRINT(X,Y)

      PRINTLN(X)

      WRITE(X)

    #endif //SERIAL_DEBUG

     

    Then in your code, you can simply use those functions instead of the Serial functions, there's no need for any other diff files.

     

    David

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
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