Show Posts
Pages: [1] 2 3 ... 6
1  Using Arduino / Programming Questions / Re: Gliding Values. on: Today at 08:50:47 am
Please use code tags.. See section 7,148850.0.html
2  Using Arduino / Programming Questions / Re: Leonardo -- Serial Issues on: Today at 08:35:21 am

No need to be getting angry mate or do you enjoy scaring beginners away from this forum?

Daufderh all you should be doing is plugging the board into USB and pressing upload.. There is no need to be touching the reset button during this process.
3  Using Arduino / Programming Questions / Re: I2C scanner not finding ATtiny using TinywireS(Rambo) on: April 14, 2014, 10:20:27 am
Yer i worked that out last night after remove all the code and then adding segments in bit by bit.
Thanks anyway
4  Using Arduino / Programming Questions / Re: I2C scanner not finding ATtiny using TinywireS(Rambo) on: April 11, 2014, 10:06:19 pm
But that is commented.. So it shouldn't affect it.. right?

An i am using the ATtiny85
5  Using Arduino / Programming Questions / Re: I2C scanner not finding ATtiny using TinywireS(Rambo) on: April 11, 2014, 06:47:08 am
Any ideas?
6  Using Arduino / Programming Questions / I2C scanner not finding ATtiny using TinywireS(Rambo) on: April 10, 2014, 10:51:52 am
I have been trying to get this working all night, but for some reason the I2C scanner written by Nick Gammon  wont detect it.. (not his fault..)
Right now i am just trying to add I2C to my current code, so I have commented out anything that was not needed for the I2C scanner to pick it up..
Can anyone tell me what i have missed
Any help is greatly appreciated. smiley

I2C Lib from

My code
rst -  - VCC
3 -  - 2
4 -  - 1
GND -  - 0
//Include libaries\\
#include <util/delay.h>
#include <avr/io.h>
#include "TinyWireS.h"

#define F_CPU 8000000
#define I2C_SLAVE_ADDRESS 0x26

#define TWI_RX_BUFFER_SIZE ( 16 )

//#define Interupt 1
//#define ledpin 3
//#define PWMPin 4

int fanRPS = 0; //Fans revalutions per second
char charToSend = ' ';
int fanDC = 85; //Fans duty cycle

// typedef struct{                  //Defines the structure for multiple fans and their dividers
// char fantype;
// unsigned int fandiv;
// }fanspec;
// fanspec fanspace[3]={{0,1},{1,2},{2,8}};
// char fan = 2;


void setup(){
//PWM setup\\
//Control Register A for Timer/Counter-0 (Timer/Counter-0 is configured using two registers: A and B)
//TCCR0A is 8 bits: [COM0A1:COM0A0:COM0B1:COM0B0:unused:unused:WGM01:WGM00]
//2<<COM0A0: sets bits COM0A0 and COM0A1, which (in Fast PWM mode) clears OC0A on compare-match, and sets OC0A at BOTTOM
//2<<COM0B0: sets bits COM0B0 and COM0B1, which (in Fast PWM mode) clears OC0B on compare-match, and sets OC0B at BOTTOM
//3<<WGM00: sets bits WGM00 and WGM01, which (when combined with WGM02 from TCCR0B below) enables Fast PWM mode
TCCR0A = 2<<COM0A0 | 2<<COM0B0 | 3<<WGM00;

//Control Register B for Timer/Counter-0 (Timer/Counter-0 is configured using two registers: A and B)
//TCCR0B is 8 bits: [FOC0A:FOC0B:unused:unused:WGM02:CS02:CS01:CS00]
//0<<WGM02: bit WGM02 remains clear, which (when combined with WGM00 and WGM01 from TCCR0A above) enables Fast PWM mode
//1<<CS00: sets bits CS01 (leaving CS01 and CS02 clear), which tells Timer/Counter-0 to not use a prescalar
TCCR0B = 0<<WGM02 | 1<<CS00;

//Control Register for Timer/Counter-1 (Timer/Counter-1 is configured with just one register: this one)
//TCCR1 is 8 bits: [CTC1:PWM1A:COM1A1:COM1A0:CS13:CS12:CS11:CS10]
//0<<PWM1A: bit PWM1A remains clear, which prevents Timer/Counter-1 from using pin OC1A (which is shared with OC0B)
//0<<COM1A0: bits COM1A0 and COM1A1 remain clear, which also prevents Timer/Counter-1 from using pin OC1A (see PWM1A above)
//1<<CS10: sets bit CS11 which tells Timer/Counter-1  to not use a prescalar
TCCR1 = 0<<PWM1A | 0<<COM1A0 | 2<<CS10;

//General Control Register for Timer/Counter-1 (this is for Timer/Counter-1 and is a poorly named register)
//1<<PWM1B: sets bit PWM1B which enables the use of OC1B (since we disabled using OC1A in TCCR1)
//2<<COM1B0: sets bit COM1B1 and leaves COM1B0 clear, which (when in PWM mode) clears OC1B on compare-match, and sets at BOTTOM
GTCCR = 1<<PWM1B | 2<<COM1B0;
OCR1C = 170;
//Interupt setup\\
// GIMSK = 1<<PCIE;
// PCMSK = 1<<PCINT1;

//Pin setup\\
// pinMode(Interupt, INPUT);
// pinMode(ledpin, OUTPUT);
// pinMode(PWMPin, OUTPUT);
// digitalWrite(ledpin, LOW);

//I2C setup\\
// TinyWireS.onReceive(receiveEvent);
// TinyWireS.onRequest(requestEvent);

// if(getRPM() < 500){
// fan = 1;
// }


void loop(){
//digitalWrite(ledpin, LOW);
fanRPS = fanDC * 5 / 10;
charToSend = char(fanRPS);


void requestEvent(){

void receiveEvent(uint8_t howMany){
// if(howMany < 1){
// return;
// }
// if(howMany > TWI_RX_BUFFER_SIZE){
// return;
// }
// howMany--;
// if(!howMany){
// return;
// }
// while(howMany--){
fanDC = TinyWireS.receive() - '0';


// ISR(PCINT0_vect){ //This is the function that the interupt calls
// if(digitalRead(Interupt) == HIGH){
// fanRPS++;
// }
// }


//int getRPM(){
// int Calc = 0;
// fanRPS = 0; //Set fanRPS to 0 ready for calculations
// PCMSK = 1<<PCINT1; //Enables interrupts
// _delay_ms(1000); //Wait 1 second
// PCMSK = 0<<PCINT1; //Disable interrupts
// Calc = ((fanRPS * 60)/fanspace[fan].fandiv); //Times fanRPS (which is apprioxiamately the fequency the fan is spinning at) by 60 seconds before dividing by the fan's divider
// return Calc;

This is some example code from that works and is detected
// the 7-bit address (remember to change this when adapting this example)
#define I2C_SLAVE_ADDRESS 0x26

// Get this from
#include <util/delay.h>
#include <avr/io.h>
#include <TinyWireS.h>

// The default buffer size, Can't recall the scope of defines right now
#define TWI_RX_BUFFER_SIZE ( 16 )

//Character variable used to echo data back.
char chrSendData;

//Variables used in getting and parsing data.
char rxChrData; //Receives the data.
char rxString[12];  //Varbiable for holding one string of data.
int rxIndex = 0; //Used to index rxString.

//Integer for holding the pwm value received from master.
int pwmValA;

void requestEvent(){ 

//Handles receiving i2c data.
void receiveEvent(uint8_t howMany)
    if (TinyWireS.available()){ 
      if (howMany < 1)
      {   // Sanity-check
      if (howMany > TWI_RX_BUFFER_SIZE)
      {   // Also insane number
      if (!howMany)
      {   // This write was only to set the buffer for next read
      {   //Gets i2c data.
          rxChrData = TinyWireS.receive();
          //Places the characters in an array one at a time.
          rxString[rxIndex] = char(rxChrData);
          //Increment the data array.
          //If a stop character is read, parse the char array and convert it to a single integer. 
          if (rxChrData == ':'){
              //This is a low memory form of parsing the char array into an intger
              pwmValA = int(100*rxString[2]+10*rxString[3]+rxString[4]);
              //Prints the parsed value.
              //Writes the parsed value to pin 1 (PB1).
              digitalWrite(3, HIGH);
              //Resets the char array index.
              rxIndex = 0; 

void setup()
    pinMode(1, OUTPUT); // OC1A, also The only HW-PWM -pin supported by the tiny core analogWrite
    //Sets up the onReceive function (what we do if we get stuff).
    //Sets up the onRequest function (what we do if asked to send something).

void loop()
//Detects a stop sending command.

//Puts the data we got into a variable to send back for error checking.
chrSendData = char(rxChrData);

7  Development / Other Software Development / Re: PWM frequency library on: March 23, 2014, 11:29:05 am
Is anyone able to modify this to work on an attiny85
8  Using Arduino / Programming Questions / Re: 25kHz PWM signal out of attiny85 on: March 23, 2014, 09:43:04 am
Is there anyone that can help?
9  Using Arduino / Programming Questions / Re: 25kHz PWM signal out of attiny85 on: March 22, 2014, 08:55:28 am
I am trying to make a PWM PC fan controller..

My current plan is to have an attiny per fan, each will supply PWM signals and send back rpm data to an uno using I2C.
The uno will be communicating to a PC  through usb so i can manage fan curves, temps, fan RPM.

I need the 25kHz PWM because the Intel specifications are a target frequency of 25kHz, with an acceptable operational range of 21 kHz to 28 kHz

I have tried reading the datasheet but I don't understand much of it..
10  Using Arduino / Programming Questions / 25kHz PWM signal out of attiny85 on: March 22, 2014, 07:40:23 am
I need to get a attiny85 to output a 25kHz PWM signal while still being able to use I2C and interrupts, but i am not sure how to do it..
I found these two threads and read through them but now i am more confused then ever.,10697.0

Any help will be greatly appreciated..
11  Using Arduino / Microcontrollers / Re: Attiny85 1000ms delay is 8 seconds long on: March 18, 2014, 08:55:38 pm
ok i will give that ago later tonight.. and will get back to you
12  Using Arduino / Microcontrollers / Attiny85 1000ms delay is 8 seconds long on: March 18, 2014, 04:02:18 am
Hi guys i am trying to use the attiny85 for a project so i have tried the blink sketch using the attiny core from arduino-tiny but the delays are 8 seconds long while using the Attiny85 @ 8Mhz core..

Using the Attiny85 @ 1Mhz core the delay is working fine..
Any help will be greatly appreciated..
13  Using Arduino / General Electronics / Re: Need 25kHz PWM signal for 4 pin PC fan on: January 29, 2014, 08:42:05 am
ok I will have a look at that.. and there is not need for a fail safe.. the Intel standard requires fans to max rpm when there in no signal
14  Using Arduino / General Electronics / Need 25kHz PWM signal for 4 pin PC fan on: January 29, 2014, 04:01:57 am
Hey Guys,
I want to make a PWM fan controller from my PC because the stock one is just horrible.. But i need help designing a circuit and finding parts..
It needs to follow this standard

I plan on being able to change the fan speed through usb..

If any one could give me a hand, that would be greatly appreciated..
15  Using Arduino / Project Guidance / Re: New Servo and Sensor project - need help!! on: October 28, 2013, 06:55:39 pm
Okay connect the servo and the HC-SR04 to the arduino and run through some example code.. Once you have done that and have an understanding of how you can get them to work together, start thinking about how you want your final project to behave. Then try to write a sketch to do that..
do you want a button that will ignore any reading from the HC-SR04,
do you want to only turn the light on if it is dark...
Then get back to us.. smiley
Pages: [1] 2 3 ... 6