newlandmark

Atmega Quad Sensor Multipurpose Development Board

 
Overview

Description of the project

 

This design is mainly for easy programming and quick application at a limited cost. I deliberately used Atmega48, which is currently cheap and easy to obtain, with a minimum of only 6 yuan (excluding postage) and high thrust ( 10ma per pin) and still 5V.

 

The key is to use Arduino IDE, but there is no Bootloader at the moment, so you need a USBASP or programmer. I use TH866A, which is quite easy to use.

 

For design reasons, I would like to suggest the configuration of sensors and actuators. What are actuators, such as relays, single-channel MOS tubes, etc. Therefore, the PCB is equipped with a large interface, which can be plugged and plugged in and out. The connection is strong and I like it.

 

It is highly recommended to use Atmega8.

 

Test method

 

The first is the test code. This section of code is mainly to verify whether the three lights can be used.

 

 

 

void setup() {
  // put your setup code here, to run once:
  pinMode(PD7,OUTPUT);
  pinMode(10,OUTPUT);
  pinMode(2,OUTPUT);
  digitalWrite(PD7,HIGH);
  digitalWrite(PB2,HIGH);
  digitalWrite(2,HIGH);
}

void loop() {
  // put your main code here, to run repeatedly:
delay(50);
digitalWrite(PD7,HIGH);
delay(50);
digitalWrite(10,LOW);
delay(50);
digitalWrite(2,LOW);

delay(50);
digitalWrite(PD7,LOW);
delay(50);
digitalWrite(10,HIGH);
delay(50);
digitalWrite(2,HIGH);
}

 

 

In terms of design considerations, the three lights function as

 

Yellow waiting: sensing

Green activation: The set value or target is sensed and the action has been triggered.

Red error: Some problems, such as sensor value errors

 

The function of the two buttons is very clear, which is to provide a good feel and be easy to install, so five JIO mechanical keyboard switches are used.

 

This model tried its best to reduce the budget on circuit components, so it did not set up the common serial port to USB, but I configured a set of lithium battery boost circuit, which can stably output 5V to Atmega48, but the input voltage cannot exceed 5V, otherwise no matter how much input Just output as much as you want.

 

Because there is no Bootloader available, there is no need to lead out pins such as DTR, so they are omitted on the board.

 

It should be noted that the connected battery must have a protection board. There is no charging circuit designed. You can choose a common charging module and connect it in parallel to the battery input terminal.

 

Note: MiniCore library needs to be installed, which has been marked on the schematic diagram.

 

Verification code

 

Cooperate with module TM1367, connect to OUT1-2, and use the library: SevenSegmentTM1637.h

 

Additional development board manager URL: https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json

 

 

// include the SevenSegmentTM1637 library
#include "SevenSegmentTM1637.h"

/* initialize global TM1637 Display object
*  The constructor takes two arguments, the number of the clock pin and the digital output pin:
* SevenSegmentTM1637(byte pinCLK, byte pinDIO);
*/
//#include"LowPower.h"
const byte PIN_CLK = 5;   // define CLK pin (any digital pin)
const byte PIN_DIO = 6;   // define DIO pin (any digital pin)
#define LEDWAIT PD2
#define LEDACT 7
#define LEDERR 10
#define MODE 4
#define SEL 3
SevenSegmentTM1637    display(PIN_CLK, PIN_DIO);

// run setup code
void setup() {
  Serial.begin(9600);         // initializes the Serial connection @ 9600 baud
  display.begin();            // initializes the display
  display.setBacklight(100);  // set the brightness to 100 %
  pinMode(3,INPUT);
  pinMode(4,INPUT);
  pinMode(LEDWAIT,OUTPUT);
  pinMode(LEDACT,OUTPUT);
  pinMode(LEDERR,OUTPUT);
  pinMode(LEDWAIT,HIGH);
  pinMode(LEDACT,LOW);
  pinMode(LEDERR,LOW);
  display.print((int)((analogRead(A7)/1024.0)*100.0)); 
  delay(1000); 
  display.print("3600");  
};
int overtime = 15000;//sleep
void down()
{
 display.clear(); 
 while(1);
//LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
}
// run loop (forever)
long int syst=0;
long int lastsyst=0;
void loop() {
  syst=millis();
  if(syst-lastsyst>overtime)
  {
    down();
  }              // display LOOP on the display
  digitalWrite(LEDWAIT,HIGH);
  if(digitalRead(MODE) == HIGH)
  {
    lastsyst = millis();
    Run();
  }
  if(digitalRead(SEL) == HIGH)
  {
    lastsyst = millis();
    timeswitch();
  }
  
}
int mode = 0;
int times = 3600;
void timeswitch()
{
  mode += 1;
  switch(mode){
    case 0:
    times = 3600;
    break;
    case 1:
    times = 1800;
    break;
    case 2:
    times = 600;
    break;
    case 3:
    times = 300; 
    break;
    default:
    mode = 0;
    times = 3600;
    break;
  }
  display.clear(); 
  display.print(times); 
  delay(200);
}
void Run()
{
  digitalWrite(LEDWAIT,LOW);
  digitalWrite(LEDACT,HIGH);
  for (int i=times; i > 0; i--) {     // loop from 0 to 100
    display.print(i);                   // display loop counter
    delay(1000);                         // wait 100 ms
  };
  display.clear();                      // clear the display
  display.print("OVER");                // print SUCC for success
  display.blink();                      // blink SUCC
  delay(10000);                       // wait 1000 ms
  digitalWrite(LEDWAIT,HIGH);
}

 

 

 

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-06-20 08:20:13

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号