However, when I opened Proteus 8.0, just the Arduino Mega 2560 and the Arduino Mini models are available in the Arduino library. I need the Arduino UNO, please. This Arduino Library for Proteus contains following boards in it: •Arduino UNO •Arduino Mega 2560 •Arduino Mega 1280 •Arduino Nano •Arduino Mini •Arduino Pro Mini Let’s get started with Arduino Library for Proteus. •First of all, download this Arduino Library for Proteus.The link is given below of this Post. STEP 5: Copy the library folder’s file and paste it in: Go to “C: Program Files (x86) Labcenter Electronics Proteus 7 Professional LIBRARY” Copy the Models folder’s file and paste it in: Go to “C: Program Files (x86) Labcenter Electronics Proteus 7 Professional Models”.
Index
- NewPing Arduino Library for Arduino
- Compatibility
- Support
- Examples
Introduction
When I first received an ultrasonic sensor I was not happy with how poorly it performed. I soon realized the problem wasn't the sensor, it was the available ping and ultrasonic libraries causing the problem. The NewPing library totally fixes these problems, adds many new features, and breathes new life into these very affordable distance sensors. Here's a list of some of the features of NewPing:
- Works with many different ultrasonic sensor models: HC-SR04, SRF05, SRF06, DYP-ME007, JSN-SR04T & Parallax PING)))™.
- Option to interface with all but the SRF06 sensor using only one Arduino pin.
- Doesn't lag for a full second if no ping echo is received like all other ultrasonic libraries.
- Compatible with the entire Arduino line-up (and clones), Teensy family (including $19.80 96Mhz 32 bit Teensy 3.2) and non-AVR microcontrollers.
- Ping sensors consistently and reliably at up to 30 times per second.
- Timer interrupt method for event-driven sketches.
- Built-in digital filter method ping_median() for easy error correction.
- Uses port registers when accessing pins for faster execution and smaller code size.
- Allows setting of a maximum distance where pings beyond that distance are read as no ping or clear.
- Ease of using multiple sensors (sketch that pings 3 sensors - sketch that pings 15 sensors using timers).
- More accurate distance calculation (cm, inches & microseconds).
- Doesn't use pulseIn, which is slow and gives incorrect results with some ultrasonic sensor models.
- Actively developed with features being added and bugs/issues addressed.
Download & Install
Save the .zip file to your desktop, then use the Importing a .zip Library instructions to import the library into the Arduino IDE.
(113,121 downloads on Google Code before being closed)
If you wish to fork this library, please create a private repository as to not confuse others trying to download the latest official version.
Show Your Appreciation
Help future development by making a small donation (the teckel@bex.net payee is correct).
Supporters (latest: June 8th, 2019):
Dave D. $5 | Jose R. $5 | Patrick G. $10 | |
Rüdiger B. $1.50 | Jason H. $5 | Lars S. $5 | Elo Software Co., LTD. $10 |
Malcolm B. $8 | K. Worden $2.50 | SF Simulation Ltd $100 | Alfredo Z. $10 |
Charles W. $10 | 3 alarm carnival productions $5 | Charlie S. $3 | Michael M. $10 |
Steven P. $10 | John A. $10 | Marc D. $5 | Kfl V. $5 |
Anatoly S. $10 | Steve A. $10 | Darryl F. $2 | Patrick H. $3 |
Javier F. $10 | Kambiz F. $5 | YourDuino.com $10 | John S. $2 |
Pete R. $5 | Wilson H. $5 | Zlatko O. $5 | Muhammad S. $10 |
JP S. $5 | Heath M. $25 | Johann G. $10 | Aung H. $10 |
Alan M. $30 | Alastair M. $20 | Davide L. $2 | Mike M. $30 |
David M. $4 | Antonio B. $1 | Carsten W. $3 | Jose N. $10 |
Martin M. $5 | Fred A. $5 | Alan H. $3 | Orlando S. $10 |
Ed N. $10 | Daniel H. $1 | Bogdan M. $5 | Soh K. $10 |
Pentagono Estudio $1 | Stephen C. $5 | Daniel D. $3 | Adam G. $10 |
Cha-Rie T. $10 | Stig M. $5 | Claudio Z. $5 | The Forge Initiative $10 |
Weyman S. $5 | Bob R. $5 | Zdenek K. $10 | Duane G. $10 |
Ronald B. (Granpa) $20 | EM Workbench $25 | Ralph H. $25 | Ron T. $5 |
Greg S. $5 | William M. $10 | Douglas M. $5 | Nikita V. $3 |
Matthew B. $10 | Olexiy L. $10 | Matt K. $3 | Charles D. $10 |
Frédérik B. $5 | YourDuino.com $10 | Silva M. $10 | David B. $10 |
Lukas M. $2 | Jonas H. $2.50 | Graeme M. $5 | Alessandro Z. $20 |
Maximilian S. $10 | Wally H. $5 | Debottam B. $2 | Tim H. $20 |
Paul M. $5 | James W. $10 | Isaac R. $2 | Erica S. $10 |
Connection Example
Constructor
NewPing sonar(trigger_pin, echo_pin [, max_cm_distance])
Initialize an ultrasonic device, trigger pin, echo pin, and optional maximum distance you wish to sensor to measure (default = 500cm).
Example:
This initializes NewPing to use pin 12 for trigger output, pin 11 for echo input, with a maximum ping distance of 200cm. max_cm_distance is optional (default = 500cm). If connecting using a single pin, specify the same pin for both trigger_pin and echo_pin as the same pin is doing both functions.
Methods
- sonar.ping([max_cm_distance]) - Send a ping and get the echo time (in microseconds) as a result. [max_cm_distance] allows you to optionally set a new max distance.
- sonar.ping_in([max_cm_distance]) - Send a ping and get the distance in whole inches. [max_cm_distance] allows you to optionally set a new max distance.
- sonar.ping_cm([max_cm_distance]) - Send a ping and get the distance in whole centimeters. [max_cm_distance] allows you to optionally set a new max distance.
- sonar.ping_median(iterations [, max_cm_distance]) - Do multiple pings (default=5), discard out of range pings and return median in microseconds. [max_cm_distance] allows you to optionally set a new max distance.
- sonar.convert_in(echoTime) - Convert echoTime from microseconds to inches.
- sonar.convert_cm(echoTime) - Convert echoTime from microseconds to centimeters.
- sonar.ping_timer(function [, max_cm_distance]) - Send a ping and call function to test if ping is complete. [max_cm_distance] allows you to optionally set a new max distance.
- sonar.check_timer() - Check if ping has returned within the set distance limit.
- NewPing::timer_us(frequency, function) - Call function every frequency microseconds.
- NewPing::timer_ms(frequency, function) - Call function every frequency milliseconds.
- NewPing::timer_stop() - Stop the timer.
History
v1.9.1 - Released 07/15/2018 - Added support for ATtiny441 and ATtiny841 microcontrollers.
v1.9.0 - Released 12/09/2017 - Added support for the ARM-based Particle devices. If other ARM-based microcontrollers adopt a similar timer method that the Particle and Teensy 3.x share, support for other ARM-based microcontrollers could be possible. Attempt to add to Arduino library manager. License changed.
v1.8 - Released 07/30/2016 - Added support for non-AVR microcontrollers. For non-AVR microcontrollers, advanced ping_timer() timer methods are disabled due to inconsistencies or no support at all between platforms. However, standard ping methods are all supported. Added new optional variable to ping(), ping_in(), ping_cm(), ping_median(), and ping_timer() methods which allows you to set a new maximum distance for each ping. Added support for the ATmega16, ATmega32 and ATmega8535 microcontrollers. Changed convert_cm() and convert_in() methods to static members. You can now call them without an object. For example: cm = NewPing::convert_cm(distance);
v1.7 - Released 09/29/2015 - Removed support for the Arduino Due and Zero because they're both 3.3 volt boards and are not 5 volt tolerant while the HC-SR04 is a 5 volt sensor. Also, the Due and Zero don't support pin manipulation compatibility via port registers which can be done (see the Teensy 3.2).
v1.6 - Released 06/17/2014 - Corrected delay between pings when using ping_median() method. Added support for the URM37 sensor (must change URM37_ENABLED from false to true). Added support for Arduino microcontrollers like the $20 32 bit ARM Cortex-M4 based Teensy 3.2. Added automatic support for the Atmel ATtiny family of microcontrollers. Added timer support for the ATmega8 microcontroller. Rounding disabled by default, reduces compiled code size (can be turned on with ROUNDING_ENABLED switch). Added TIMER_ENABLED switch to get around compile-time '_vector_7' errors when using the Tone library, or you can use the toneAC, NewTone or TimerFreeTone libraries. Other speed and compiled size optimizations.
Proteus Library Download
v1.5 - Released 8/15/2012 - Added ping_median() method which does a user specified number of pings (default=5) and returns the median ping in microseconds (out of range pings ignored). This is a very effective digital filter. Optimized for smaller compiled size (even smaller than sketches that don't use a library).
v1.4 - Released 7/14/2012 - You can now interface with all but the SRF06 sensor using only one Arduino pin. Added support for the Parallax PING)))™ sensor. You can also interface with the SRF06 using one pin if you install a 0.1uf capacitor on the trigger and echo pins of the sensor then tie the trigger pin to the Arduino pin (doesn't work with Teensy). To use the same Arduino pin for trigger and echo, specify the same pin for both values. Various bug fixes.
v1.3 - Released 6/8/2012 - Big feature addition, event-driven ping! Uses Timer2 interrupt, so be mindful of PWM or timing conflicts messing with Timer2 may cause (namely PWM on pins 3 & 11 on Arduino, PWM on pins 9 and 10 on Mega, and Tone library). Simple to use timer interrupt functions you can use in your sketches totaly unrelated to ultrasonic sensors (don't use if you're also using NewPing?'s ping_timer because both use Timer2 interrupts). Loop counting ping method deleted in favor of timing ping method after inconsistant results kept surfacing with the loop timing ping method. Conversion to cm and inches now rounds to the nearest cm or inch. Code optimized to save program space and fixed a couple minor bugs here and there. Many new comments added as well as line spacing to group code sections for better source readability.
NOTE: For Teensy/Leonardo (ATmega32U4) the library uses Timer4 instead of Timer2. Also, only 16Mhz microcontrollers are supported with the timer methods, which means the ATmega8 and ATmega128 will not work with the timer methods. However, the standard ping method should work just fine on 8Mhz microcontrollers.
v1.2 - Released 5/24/2012 - Lots of code clean-up thanks to Adruino Forum members. Rebuilt the ping timing code from scratch, ditched the pulseIn code as it doesn't give correct results (at least with ping sensors). The NewPing? library is now VERY accurate and the code was simplified as a bonus. Smaller and faster code as well. Fixed some issues with very close ping results when converting to inches. All functions now return 0 only when there's no ping echo (out of range) and a positive value for a successful ping. This can effectively be used to detect if something is out of range or in-range and at what distance. Now compatible with Arduino 0023.
v1.1 - Released 5/16/2012 - Changed all I/O functions to use low-level port registers for ultra-fast and lean code (saves from 174 to 394 bytes). Tested on both the Arduino Uno and Teensy 2.0 but should work on all Arduino-based platforms because it calls standard functions to retrieve port registers and bit masks. Also made a couple minor fixes to defines.
v1.0 - Released 5/15/2012 - Initial release.
Compatibility
Ultrasonic Sensors
- HC-SR04, SRF05, SRF06, DYP-ME007, JSN-SR04T, Parallax PING)))™
Platforms - All Methods
- Arduino Uno, Mega, Mega 2560, Leonardo, Micro, Mini, Nano, Pro, Pro Mini, Fio, Mega ADK, Ethernet, Robot, Bluetooth, Yún, Lilypad, Duemilanove, Diecimila, Teensy 1.x, Teensy 2.x, Teensy 3.x, Particle Photon, Particle Electron?, ATmega328, ATmega168, ATmega8, ATmega16, ATmega32, ATmega8535
Platforms - No Timer Methods
The following won't work with these methods: ping_timer(), check_timer(), timer_us(), timer_ms() & timer_stop(). The reason is either because the microcontroller doesn't have a suitable timer (like the ATtiny line) or doesn't have built-in standardized timer functionality (like the Zero, Due, and other non-AVR microcontrollers). The Tiny 3.x line is the exception due to its built-in standardized timer functionality, so it works with all methods.
- Arduino Zero, Due, MKR1000, Gemma, ATmega128, ATtiny24, ATtiny44, ATtiny84, ATtiny25, ATtiny45, ATtiny85, ATtiny261, ATtiny461, ATtiny861, ATtiny43U, and most ARM microcontrollers not noted above
Support
Support Forum
Issue Tracking
- NewPing issue tracking - I guess it's worth trying out how Bitbucket's issue tracking works. Create an issue in the Issues section and we'll see how it goes.
Ultrasonic Library Arduino For Proteus 8 Professional Free Download
Timer 2 Conflict
- Having a conflict with the tone library or another library using timer 2? Instead of the tone library, use my NewTone or toneAC libraries which instead uses timer 1 (and also has many other advantages). Or use my Timer Free Tone library which doesn't use any timers to generate tones.
Multiple Definition of '_vector_7' Error
- Wiki help page on how to resolve the multiple definition of '_vector_7' error.
Help with 15 Sensors Sketch
- Trying to use the 15 sensor sketch and need some help? There's a Wiki help page with loads of information.
Examples
Simple NewPing Sketch
Single Pin Sketch
Ping 3 Sensors Sketch
Event Timer Sketch
Timer Median Sketch
15 Sensors Sketch
Library Arduino For Proteus 8
NOTICE! - For assistance this this sketch, see: Help with 15 Sensors Example Sketch. But seriously, you probably should REALLY consider using the sketch that pings 3 sensors instead, you've been warned!
This sketch is designed for seasoned programming experts, don't use unless you really know what you're doing!
Cool User Projects Using NewPing
My Other Arduino Libraries
NewPing Works with many ultrasonic sensors, can communicate using only one pin, very low lag, fast (up to 30 pings per second), timer interrupt method for event-driven sketches, light code, and much more.
LCDBitmap Arduino library that allows you to create a tiny 20x16 pixel bitmap (raster) display on a normally character-only Hitachi HD44780 based LCD display. Typical drawing functions like line, rectangle, invert, etc. Control is right down to the pixel level.
toneAC Replacement to the standard tone library with the advantage of nearly twice the volume, higher quality, can produce higher frequencies, 1.5k smaller compiled code, and less stress on the speaker.
toneAC2 Replacement to the standard tone library with the advantage of nearly twice the volume, 800 bytes smaller compiled code size, and less stress on the speaker.
NewTone About 1,200 bytes smaller code size than the standard tone library, faster execution time, exclusive use of port registers for fastest and smallest code, higher quality sound output than tone library.
TimerFreeTone Replacement to the standard tone library but without using timers. Also over 1.5k smaller compiled code, exclusive use of port registers, and compatible with ATmega, ATtiny, and ARM-based microcontrollers.
Updated
We have already seen in the article “ARDUINO Simulation PCB and 3D Models Libraries for Proteus”, how to add the ARDUINO simulation, footprints and 3D models libraries to Proteus. Now we are going to see how is simple to use this components models for simulating ARDUINO projects. We can download for example the controlling LED project implemented with a microcontroler:
Fig. 1 Simple project implemented with a microcontroller model
We can replace the microcontroller, capacitors and crystal oscillator with the ARDUINO UNO simulation model:
Fig. 2 The same project above implemented with ARDUINO UNO simulation model
Let ‘s note that the PB5 output has a different numeration in the two models, but the .hex file should work for both, and also for the project implemented with ARDUINO Pro Mini model.
Click the right mouse button, over the model, and choose “Edit Properties”:
Fig. 3 Edit Properties
Load the hex file of the blink project in the “Program File” edit field:
Fig. 4 Load the Hex file
finally, let ‘s run the simulation:
Fig. 5 Run th simulation
Regarding the PCB assignment, let ‘s note that the only component that hasn ‘t an assigned footprint is the animated red LED:
Fig. 6 PCB package not specified for the LED component
We have to assign one to it: select the component, right mouse button, and let ‘s choose “Make Device”:
Fig. 7 Make Device window
Click onNext, and the “Add/Edit”:
Fig. 8 Click on “Add/Edit” button
It ‘s shown the “Package Device” window:
Fig. 9 Package Device window
Click on “Add” button and type the keyword “led” on the “Pick Packages” window, and select LED PACKAGE
Fig. 10 Type “led” on Pick Packages window
Double click over the first line, under the letter “A”
Fig. 11 Double click
and click on the anode pin of the PCB:
Fig. 12 Click on Anode pin
Same procedure for the other pin:
Fig. 13 Click on Cathode pin
Now, let ‘s click on the “Assign Packages” button,
Fig. 14 Packagings window shows the PCB assigned
Next button, select PACKAGE from the Component Properties and Definitions options:
Fig. 15 Select PACKAGE
Leave blank the Datasheet Filename edit field:
Ultrasonic Library Arduino For Proteus 8 Professional 2
Fig. 16 leave blank the datasheet field
Choose USERDVC library, for example:
Download Library Arduino For Proteus
Fig. 17 choose USERDVC library
Ultrasonic Library Arduino For Proteus 8 Professional Download
Confirm the update request in the next message box
Fig. 18 Update message box