Show Posts
Pages: [1] 2 3 ... 10
1  Using Arduino / General Electronics / Read an electronic signal from a music amplifier without affecting it on: April 05, 2014, 07:01:47 am
Hi!
I just built an Amplifier for my home theatre subwoofer, and I'm quite happy with it. The only problem is that I'll manually have to turn it on and off, while the commercial ones have a sort of "auto detecting" the music signal.

I've been using Arduino for quite some time now, and I know how to use analogRead to measure voltage levels.
The difference is that I don't want the Arduino to affect the signal in any way. Is it possible to build an electronic circuit that will achieve these criteria?
2  Using Arduino / Microcontrollers / Re: Atmega 168 And ATmega8 on Arduino UNO on: March 27, 2014, 08:00:01 am
Don't listen to them! If you have an UNO with a removable Atmega328, you can place an Atmega8 or Atmega168 instead of the original Atmega328p. These microcontrollers have the same pinout, and there exist Optiboot bootloaders for all of them.
Optiboot is just an optimized bootloader that is faster and does not require more than 512b of memory.

I've used atmega8 a lot in small projects that doesn't require more space than 8kb. You can of course use the original ATmega8/168 bootloader, but I strongly recommend Optiboot.
You just place the atmega8/168 into the UNO board, choose the right board/bootloader under the Tools > Boards menu, and clock "Burn bootloader". You'll also need an ISP programmer, such as USBasp, AVRisp or an Arduino ISP.

take a look at post no. 3 in this topic. I wrote a small guide to get started.
3  Using Arduino / Programming Questions / Re: For-loop inside if statement - possible? on: March 26, 2014, 01:36:47 pm
Yes, Basically I want to compare two arrays. I've never used memcmp() before. Is there a different syntax compared to c++?
4  Using Arduino / Programming Questions / For-loop inside if statement - possible? on: March 26, 2014, 12:43:26 pm
Hi!
I'm working on a RFID project, where I've scan an RFID card, and saved its unique ID into an array.
I want the Arduino to recognize multiple RFID cards, so I've created some arrays to check what card have been scanned..

I got these arrays, and when I scan a card, the ID is stored into the UniqueID array.
Code:
byte keyChain[4] = {0x4D, 0x9A, 0xE2, 0xEA};
byte creditCard[4] = {0x25, 0x30, 0xFD, 0x2B};
byte UniqueID[4];

I've been using this to check what card have been scanned:
Code:
   
         if(UniqueID[0] == creditCard[0] && UniqueID[1] == creditCard[1] &&
                UniqueID[2] == creditCard[2] && UniqueID[3] == creditCard[3]) {
                Serial.println("");  
                Serial.println("Creditcard scanned!");
                Serial.println(" ");
                digitalWrite(14, HIGH);  
                delay(1000);
                }

As you can see this code is a bit hairy, and I want to make it smaller and more elegant if that's possible.

I was thinking something like this, but I can't figure how to get it to work! Is it possible to write it this way?
Code:
               if( for(int i = 0; i<4; i++) { creditCard[i] == UniqueID[i]; } )
                  { doSomeStuffHere(); }
5  Using Arduino / General Electronics / Measuring RTC backup battery; How much current will an arduino draw ? on: February 09, 2014, 03:41:07 pm
Hi!
I'm working on a door logging machine that displays time on a a display.
I'm using a DS1307 with a backup battery.
I want the Arduino to constantly measure the voltage left on the little backup battery, and write on the screen when the voltage is critically low.

I know how I measure voltage, but  will this draw a noticeable amount of current from the battery?
I want the little button cell to last as long as possible.
6  Using Arduino / Programming Questions / Re: Can Arduino handle 8 bit ASCII? on: November 07, 2013, 06:40:31 am
the printer can handle norwegian characters, and if I for example want to print the character Å, I send the decimal value 148, and tell the printer to print. The problem is that I can't figure figure out how to convert a special character  to ascii values above 127
7  Using Arduino / Programming Questions / Can Arduino handle 8 bit ASCII? on: November 07, 2013, 05:45:02 am
Hi! Is it possible to use 8-bit ASCII characters with the Arduino?
I'm currently interfacing with an old parallel printer that support 8-bit ASCII, but I cant print special norwegian
characters like "æ, Æ, ø, Ø, å, Å.

Ofcource I can for the printer to print just one Character at the time, by sending the ASCII decimal value, but I want the Arduino to convert a sentence like "Dette er en test på norsk!"  and send it right out to the printer.

I'm using a shift shift register to feed the printer, and the code looks like this:

Code:
void printChar(char* value) {
    while (digitalRead(busy) == HIGH) {}   
    String mystring(value);
    for (int i = 0; i < 20; i++) {  //i should be larger than upper bound
        digitalWrite(latchPin, LOW);
        shiftOut(dataPin, clockPin, MSBFIRST, mystring[i]);   
        digitalWrite(latchPin, HIGH);
        digitalWrite(strobe, LOW);
        delay(2);
        digitalWrite(strobe, HIGH);
        delay(5);
     }   
  while (digitalRead(busy) == HIGH) {}   
}
8  Using Arduino / Programming Questions / Re: Diffrece between byte and uint8_t in functions on: October 26, 2013, 08:17:36 am
So does that mean that uint8_t and uint16_t is universal to all (most) C/C++/C# compilers?
So with the arduino compiler uint8_t and byte are the same, and uint16_t and int are the same.
I'll think i'll stick with the uint_t variant, since we're going to program in C# the next semester at school. Better keep it universal smiley-wink
9  Using Arduino / Programming Questions / Diffrece between byte and uint8_t in functions on: October 26, 2013, 08:08:28 am
Hi! Just a quick question:

What's the diffrence between using "byte" and using "uint8_t in functions?
I've discovered that this function works with both, but I've seen a lot of people using uint8_t instead of byte.

Code:
void ledBar(uint8_t value) {
    digitalWrite(led_latchPin, LOW);
    shiftOut(led_dataPin, led_clockPin, MSBFIRST, value); 
    digitalWrite(led_latchPin, HIGH);
   }

Compared to

Code:
void ledBar(byte value) {
    digitalWrite(led_latchPin, LOW);
    shiftOut(led_dataPin, led_clockPin, MSBFIRST, value); 
    digitalWrite(led_latchPin, HIGH);
   }
10  Using Arduino / Programming Questions / Re: make rotary encoder code stop at a given value on: October 22, 2013, 04:33:03 pm
aw! I didn't inspect the library very well, so I didn't realize there was a write function!
The code now works like a charm smiley-grin Thanks a lot for your help! smiley
11  Using Arduino / Programming Questions / Re: make rotary encoder code stop at a given value on: October 20, 2013, 02:51:32 pm
I think I'm using the right rotary encoder. It have three pins; one goes to ground, and the other two goes to pin 2 and 3.
I'm using this encoder library: http://www.pjrc.com/teensy/td_libs_Encoder.html
12  Using Arduino / Programming Questions / Re: make rotary encoder code stop at a given value on: October 20, 2013, 01:53:16 pm
overloadValue is just  how many times I've trigged the encoder. If I trigged it 60 times clockwise, I'll have to trig it 10 times counter clockwise to make it count down from 50, 49, 48 ...
13  Using Arduino / Programming Questions / make rotary encoder code stop at a given value on: October 20, 2013, 01:41:34 pm
Hi!
I'm trying to get my rotary encoder counter code to stop at the value 0 or 50.
if I use this piece of code:
Code:
 
newPosition = myEnc.read()/2;
if (newPosition != oldPosition) {
   oldPosition = newPosition;    
   Serial.println(newPosition);
 
   if(newposition >= 50) {
    oldPosition =50;
    newPosition = 50; }
 }

the counter stops counting values above 50. the problem is that if I continue to turn the rotary encoder after the value 50 is reached, I'll have to turn the rotary encoder "overloadValue - 50" times before i'll reach 49 again.

is there any way around this?

I'm using the encoder library:


Code:
/* Encoder Library - Basic Example
 * http://www.pjrc.com/teensy/td_libs_Encoder.html
 *
 * This example code is in the public domain.
 */

#include <Encoder.h>

// Change these two numbers to the pins connected to your encoder.
//   Best Performance: both pins have interrupt capability
//   Good Performance: only the first pin has interrupt capability
//   Low Performance:  neither pin has interrupt capability
Encoder myEnc(2, 3);
//   avoid using pins with LEDs attached

int value = 2;
long newPosition;

void setup() {
  Serial.begin(9600);
  Serial.println("Basic Encoder Test:");
}

long oldPosition  = -999;

void loop() {
  
  newPosition = myEnc.read()/2;
  if (newPosition != oldPosition) {
   oldPosition = newPosition;    
   Serial.println(newPosition); }
  
  
}
14  Using Arduino / Programming Questions / Re: need help to make universal print command on: September 30, 2013, 03:14:49 pm
I'm currently using pin 3-10 as data pins, pin 2 as strobe and pin 11 as busy.
Is this the right way to write that?

Code:
#include "ParPrinter.h"
#define strobe 2
#define busy 11

ParPrinter::ParPrinter()
{
  // define pins and pinmode here
  // tip better use an array for the datapins
  // e.g.

  pinMode(strobe, OUTPUT);
  for (int i=0; i<8; i++)
  {
    pinMode(pin[i+3], OUTPUT);
  }
  pinMode(busy, INPUT);
}

// write() must implement the virtual write of the Print class
size_t ParPrinter::write(uint8_t data)
{
  while(digitalRead(busy) == HIGH) {}

  for (int i=0; i<8; i++)
  {
    digitalWrite(pin[i+1], bitRead(data, i) );
  }
                 
  digitalWrite(strobe, LOW);
  delay(2);
  digitalWrite(strobe, HIGH);
  while (digitalRead(busy) == HIGH) {}   
 
  return 1;
}
// -- END OF FILE --
15  Using Arduino / Programming Questions / Re: need help to make universal print command on: September 30, 2013, 02:34:34 pm
No, it's not homework, I just found a ton of old printer lying around at my school, and I could have as many as I want. Its an Continuous stationery printer http://en.wikipedia.org/wiki/Continuous_stationery, so I don't think I'll run out of paper.
This printer have a parallel interface, but the plan is to build in an arduino inside this printer so I can just use the "Serial.print()" function from another arduino, and use this as a debugger or a console smiley

Pages: [1] 2 3 ... 10