• 博客园logo
  • 会员
  • 周边
  • 众包
  • 新闻
  • 博问
  • 闪存
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
MKT-porter
博客园    首页    新随笔    联系   管理    订阅  订阅
Arduino 433 自定义发射

 

/*
  This is a minimal sketch without using the library at all but only works for
  the 10 pole dip switch sockets. It saves a lot of memory and thus might be 
  very useful to use with ATTinys :)
  
  https://github.com/sui77/rc-switch/
*/

int RCLpin = 7;

void setup() {
    pinMode(RCLpin, OUTPUT);
}

void loop() {
    RCLswitch(0b010001000001);  // DIPs an Steckdose: 0100010000 An:01
    delay(2000);

    RCLswitch(0b010001000010);  // DIPs an Steckdose: 0100010000 Aus:10
    delay(2000);    
}

void RCLswitch(uint16_t code) {
    for (int nRepeat=0; nRepeat<6; nRepeat++) {
        for (int i=4; i<16; i++) {
            RCLtransmit(1,3);
            if (((code << (i-4)) & 2048) > 0) {
                RCLtransmit(1,3);
            } else {
                RCLtransmit(3,1);
            }
        }
        RCLtransmit(1,31);    
    }
}

void RCLtransmit(int nHighPulses, int nLowPulses) {
    digitalWrite(RCLpin, HIGH);
    delayMicroseconds( 350 * nHighPulses);
    digitalWrite(RCLpin, LOW);
    delayMicroseconds( 350 * nLowPulses);
}

  

posted on 2018-01-05 22:23  MKT-porter  阅读(415)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3