background preloader

PortManipulation

PortManipulation
Reference Language | Libraries | Comparison | Changes Port registers allow for lower-level and faster manipulation of the i/o pins of the microcontroller on an Arduino board. The chips used on the Arduino board (the ATmega8 and ATmega168) have three ports: B (digital pin 8 to 13) C (analog input pins) D (digital pins 0 to 7) Each port is controlled by three registers, which are also defined variables in the arduino language. DDR and PORT registers may be both written to, and read. PORTD maps to Arduino digital pins 0 to 7 DDRD - The Port D Data Direction Register - read/write PORTD - The Port D Data Register - read/write PIND - The Port D Input Pins Register - read only PORTB maps to Arduino digital pins 8 to 13 The two high bits (6 & 7) map to the crystal pins and are not usable DDRB - The Port B Data Direction Register - read/write PORTB - The Port B Data Register - read/write PINB - The Port B Input Pins Register - read only PORTC maps to Arduino analog pins 0 to 5. Examples See Related:  ArduinoArduinoCoding Tricks

playground - BitMath Note: This page was inspired by a conversation that took place in the Arduino forum. Table of Contents Introduction Often when programming in the Arduino environment (or on any computer, for that matter), the ability to manipulate individual bits will become useful or even necessary. Saving memory by packing up to 8 true/false data values in a single byte. In this tutorial, we first explore the basic bitwise operators available in the C++ language. The Binary System To better explain the bitwise operators, this tutorial will express most integer values using binary notation, also known as base two. In the familiar decimal system (base ten), a number like 572 means 5*102 + 7*101 + 2*100. It is crucial that you understand how the binary system works in order to follow the remainder of this tutorial. Unfortunately, most C++ compilers do not have any means of expressing binary numbers directly in source code. Bitwise AND Bitwise OR The bitwise OR operator in C++ is the vertical bar symbol, |. or

StepperBipolarCircuit - Aurora Reference Language | Libraries | Comparison | Changes Two Pins Four Pins Reference Home Arduino Ethernet Shield Tutorial The Ethernet Shield is based upon the W51000 chip, which has an internal 16K buffer. It has a connection speed of up to 10/100Mb. This is not the fastest connection around, but is also nothing to turn your nose up at. It relies on the Arduino Ethernet library, which comes bundled with the development environment. There is also an on-board micro SD slot which enables you to store a heck-of-a-lot of data, and serve up entire websites using just your Arduino. The board also has space for the addition of a Power over Ethernet (PoE) module, which allows you to power your Arduino over an Ethernet connection. For a full technical overview, see the official Ethernet Shield page.

Maximum pin toggle speed Hmm. This was asked over on AVRFreaks, and it's FREQUENTLY a Frequently asked question about CPUs/etc, though I don't recall ever seeing it asked here. Since I actually did the experiment, I'll post the answer anyway! while (1) { digitalWrite(3, 1); digitalWrite(3, 0); } produces a 106.8kHz square wave on digital pin 3 in Arduino 0010, 0011, and 0012. cli(); while (1) { PORTD |= 0x8; PORTD &= ~0x8; } on the same board runs at 2.667MHz. Arduino Port Manipulation Control Arduino I/O pins faster and with less code in chapter forty-three of a series originally titled “Getting Started/Moving Forward with Arduino!” by John Boxall – a series of articles on the Arduino universe. [Updated 19/01/13] In this article we are going to revisit the I/O pins, and use what is called “Port Manipulation” to control them in a much faster manner than using digitalWrite()/digitalRead(). Why? Speed! Memory! Once again I will try and keep things as simple as possible. First, we’ll use the I/O as outputs. D – for digital pins seven to zero (bank D)B – for digital pins thirteen to eight (bank B)C – for analogue pins five to zero (bank … C!) Register C can control analogue pins seven to zero if using an Arduino with the TQFP style of ATmega328, such as the Nano or Freetronics EtherTen). It is very simple to do so. where y is the register type (B/C/D) and xxxxxxxx are eight bits that determine if a pin is to be an input or output. And the results from the MSO. Like this:

Programming an ATtiny w/ Arduino This tutorial shows you how to program an ATtiny45 or ATtiny85 microcontroller using the Arduino software and hardware. The ATtiny45 and ATtiny85 are small (8-leg), cheap ($2-3) microcontrollers that are convenient for running simple programs. This tutorial is obsolete! See the updated version of this tutorial (with support for Arduino 1.0). They are almost identical, except that the ATtiny85 has twice the memory of the ATtiny45 and can therefore hold more complex programs. We like to use both of them with paper circuits and other craft electronics. Materials and Tools For this tutorial, you’ll need: Arduino Uno or Duemilanove (w/ an ATmega328, not an older board with an ATmega168) ATtiny45 or ATtiny85 (8-pin DIP package) a 10 uF capacitor (e.g. from Sparkfun or from Digi-Key ) a breadboard jumper wires For more information, see our list of materials and parts and our list of prototyping supplies . Software Download: Arduino software , attiny45_85.zip The ATtiny45 / ATtiny85 Microcontroller

Schematic for Arduino Sensor Shield v5.0 ? - Arduino Forum - Aurora It's very unfortunate that the term "Arduino" is used both for a specific company name and also for generic module compatibility from any manufacturer. Arduino is a trademark that many folk in various countries are only too happy to violate. Consider how easy it is to violate said trademark, BTW. Unlike Digilent and other companies products' you don't even need to reverse-engineer the schematics, code, etc. because it's all published for the world to use. My Mega2560 is marked "WWW.ARGUINO.CC" and "DESIGN IN ITALY". Well, reads like a knockoff whose intent was to skirt the trademarked name, much like "Rotex", "Prolex", and other variations of a well-known watch brand. My "Arduino Sensor Shield v5.0" has "SainSmart" stenciled on the reverse side, yet Arduino.cc sells an apparently identical shield with an identically-colored PCB. Cheers and best of luck with your project. --- Edited to acknowledge that Digilent publishes its Eagle files ----

playground - RegulatedPositiveVoltageBooster Outputs 1/4 Watt, up to +60V DC Max Accepts any input voltage (1V minimum) Uses a simple, flexible circuit Warning: If you don't follow the instructions carefully, wiring this circuit wrong can damage your Arduino. The output voltage of this circuit must not be applied to the digital IO of the Arduino. Arduino Project and Schematic Download RegVoltageBooster.zip Schematic Pictures The Arduino 5V boosted to 40V, with a hand made inductor. The same circuit, with the Arduino regulating at 9V instead. Circuit Theory Inductors resist changes in current. There are many ways to explain the relationship between PWM (analog output) and output voltage. Don't worry about the gain of the transistor. The exact inductance of L1 doesn't matter. If you're trying to get more than one watt, then use a darlington pair. Software Summary The Arduino ATMega168 regulates the output voltage. The program was written for both the ATMega8 or ATMega168. Inductors that work Each inductor behaved a bit differently. Safety

AttachInterrupt Reference Language | Libraries | Comparison | Changes Description Specifies a named Interrupt Service Routine (ISR) to call when an interrupt occurs. Replaces any previous function that was attached to the interrupt. Most Arduino boards have two external interrupts: numbers 0 (on digital pin 2) and 1 (on digital pin 3). The table below shows the available interrupt pins on various boards. The Arduino Due board has powerful interrupt capabilities that allows you to attach an interrupt function on all available pins. Note Inside the attached function, delay() won't work and the value returned by millis() will not increment. Using Interrupts Interrupts are useful for making things happen automatically in microcontroller programs, and can help solve timing problems. About Interrupt Service Routines ISRs are special kinds of functions that have some unique limitations most other functions do not have. Generally, an ISR should be as short and fast as possible. Syntax Parameters Returns none Example

Electronics : Microprocessors : I2C - Two-Wire Peripheral Interface - for Arduino Tip A summary of everything shown below is available further down this page: This post describes how the I2C (Inter-Integrated Circuit, or "Two-Wire") interface works, with particular reference to the Arduino Uno which is based on the ATmega328P microprocessor chip. A lot of the details however will be of more general interest. The Two-Wire interface is extremely useful for connecting multiple devices, as they can all share the same two pins (plus a ground return). This is because the devices are "addressable". Because of this you could have an LCD screen (say) at address 10, a keyboard at address 11, and so on. More information about I2C at: More information about the Arduino Two-Wire interface at: Other protocols Pinouts On the Arduino Uno the pins you need are: Analog port 4 (A4) = SDA (serial data)Analog port 5 (A5) = SCL (serial clock) Of course, you also need to connect the GND (ground) pins to complete the circuit. Tip:

Txapuzas electrónicas: PaperTeclado: Un teclado con una hoja impresa de papel Introducción ¿Necesitas unos pulsadores para tu proyecto con un microcontrolador? Lo puedes hacer muy fácilmente, simplemente imprimiendo una hoja de papel a la que se fijarán con cinta adhesiva unos cables. NOTA: Sólo funciona con hojas impresas en impresora de inyección de tinta. Este proyecto recoje la idea de unos documentos de CienciaRedCreativa: En estos documentos se demuestra que: "Las bandas realizadas sobre un papel con una impresora de inyección de tinta son ligeramente conductoras, y que a medida que aumenta la longitud de la banda, la resistencia y que a medida que aumenta el ancho de la banda la resistencia eléctrica disminuye". Funcionamiento Realización Hacemos dos pequeños cortes en el lateral para los cables: PaperTecladoN8.pde

RotaryEncoders - Aurora ALPS STEC12E07 Encoder A rotary or "shaft" encoder is an angular measuring device. It is used to precisely measure rotation of motors or to create wheel controllers (knobs) that can turn infinitely (with no end stop like a potentiometer has). Some of them are also equipped with a pushbutton when you press on the axis (like the ones used for navigation on many music controllers). I've written a little sketch to read a rotary controller and send its readout via RS232. It simply updates a counter (encoder0Pos) every time the encoder turns by one step, and sends it via serial to the PC. This works fine with an ALPS STEC12E08 encoder which has 24 steps per turn. I learned about how to read the encoder from the file encoder.h included in the Arduino distribution as part of the AVRLib. Example 1 Oh, a few notes: I'm not sure about the etiquette of this, but I'm just going to add onto this tutorial. Below is an image showing the waveforms of the A & B channels of an encoder. Interrupt Example

Related: